public void OnPeerConnected(NetPeer peer) { Console.WriteLine("[Client] connected to: {0}:{1}", peer.EndPoint.Host, peer.EndPoint.Port); NetDataWriter dataWriter = new NetDataWriter(); for (int i = 0; i < 5; i++) { dataWriter.Reset(); dataWriter.Put(0); dataWriter.Put(i); peer.Send(dataWriter, SendOptions.ReliableUnordered); dataWriter.Reset(); dataWriter.Put(1); dataWriter.Put(i); peer.Send(dataWriter, SendOptions.ReliableOrdered); dataWriter.Reset(); dataWriter.Put(2); dataWriter.Put(i); peer.Send(dataWriter, SendOptions.Sequenced); dataWriter.Reset(); dataWriter.Put(3); dataWriter.Put(i); peer.Send(dataWriter, SendOptions.Unreliable); } //And test fragment byte[] testData = new byte[13218]; testData[0] = 192; testData[13217] = 31; peer.Send(testData, SendOptions.ReliableOrdered); }
public void OnNetworkReceive(NetPeer peer, NetDataReader reader) { //echo peer.Send(reader.Data, SendOptions.ReliableUnordered); //fragment log if (reader.AvailableBytes == 13218) { Console.WriteLine("[Server] TestFrag: {0}, {1}", reader.Data[0], reader.Data[13217]); } }