LiteNetLib
LiteNetLib 1.3.1
.NET Standard 2.0(Mono, .NET Core, .NET Framework)용 Lite의 안정적인 UDP 라이브러리
HighLevel API 부분 : LiteEntitySystem
디스코드 채팅 :
0.9.x용 OLD BRANCH(및 예제)
Unity의 작은 게임 예제
선적 서류 비치
( 경고! 마스터 브랜치가 불안정할 수 있습니다! )
EventBasedNetListener listener = new EventBasedNetListener ( ) ;
NetManager client = new NetManager ( listener ) ;
client . Start ( ) ;
client . Connect ( "localhost" /* host ip or name */ , 9050 /* port */ , "SomeConnectionKey" /* text key or NetDataWriter */ ) ;
listener . NetworkReceiveEvent += ( fromPeer , dataReader , deliveryMethod , channel ) =>
{
Console . WriteLine ( "We got: {0}" , dataReader . GetString ( 100 /* max length of string */ ) ) ;
dataReader . Recycle ( ) ;
} ;
while ( ! Console . KeyAvailable )
{
client . PollEvents ( ) ;
Thread . Sleep ( 15 ) ;
}
client . Stop ( ) ;
EventBasedNetListener listener = new EventBasedNetListener ( ) ;
NetManager server = new NetManager ( listener ) ;
server . Start ( 9050 /* port */ ) ;
listener . ConnectionRequestEvent += request =>
{
if ( server . ConnectedPeersCount < 10 /* max connections */ )
request . AcceptIfKey ( "SomeConnectionKey" ) ;
else
request . Reject ( ) ;
} ;
listener . PeerConnectedEvent += peer =>
{
Console . WriteLine ( "We got connection: {0}" , peer ) ; // Show peer ip
NetDataWriter writer = new NetDataWriter ( ) ; // Create writer class
writer . Put ( "Hello client!" ) ; // Put some string
peer . Send ( writer , DeliveryMethod . ReliableOrdered ) ; // Send with reliability
} ;
while ( ! Console . KeyAvailable )
{
server . PollEvents ( ) ;
Thread . Sleep ( 15 ) ;
}
server . Stop ( ) ;