Beispiel #1
0
 //发送消息(上线提醒)
 private void SendtoClientString(UserInfo user, string message)
 {
     var bytes = Encoding.UTF8.GetBytes(message);
     udpClient.Send(bytes, bytes.Length, user.RemoteIPEndpoint);
 }
Beispiel #2
0
 //登陆和退出
 private void SendMessageToServer(bool isLogin)
 {
     var userInfo = new UserInfo(this.txtUserName.Text, localEndPoint, isLogin);
     var bytes = SerializerHelper.ConvertObjectToBytes<UserInfo>(userInfo);
     udpClient.Send(bytes, bytes.Length, serverEndpointUdp);
 }
Beispiel #3
0
 //发送应答消息
 private void SendAcceptMessage(UserInfo user)
 {
     var loginInfo = new LoginInfo(true, tcpPort);
     //var messageStream = new MemoryStream();
     //new XmlSerializer(typeof(LoginInfo)).Serialize(messageStream, loginInfo);
     var messageBytes = SerializerHelper.ConvertObjectToBytes<LoginInfo>(loginInfo);
     udpClient.Send(messageBytes, messageBytes.Length, user.RemoteIPEndpoint);
 }