NetPeerConfiguration config1 = new NetPeerConfiguration("chat");//参数是一个字符串标识,前后端一致。
config1.AutoFlushSendQueue = false;
// config1.EnableMessageType(NetIncomingMessageType.ConnectionLatencyUpdated);//监听收发心跳的事件。
s_client = new NetClient(config1);
s_client.Start();
SendOrPostCallback m_receiveCallBack = new SendOrPostCallback(OnReceiveMessage);//收发消息的回调
s_client.RegisterReceivedCallback(m_receiveCallBack, new SynchronizationContext());
NetOutgoingMessage hail = s_client.CreateMessage("This is the hail message");
s_client.Connect("103.200.30.194", 14242, hail);
NetPeerConfiguration config1 = new