Example #1
0
 /// <summary>
 /// Receive message from server
 /// </summary>
 public void ReceiveMessage()
 {
     while (true)
     {
         try
         {
             byte[]        data    = new byte[RxDBufferSize];
             StringBuilder builder = new StringBuilder();
             do
             {
                 int count = Network_stream.Read(data, 0, data.Length);
                 builder.Append(Encoding.Unicode.GetString(data, 0, count));
             }while (Network_stream.DataAvailable);
             NewMassageEvent?.Invoke(Client, builder.ToString());
         }
         catch
         {
             Disconnect();
         }
     }
 }
Example #2
0
 /// <summary>
 /// Save message from client
 /// </summary>
 /// <param name="tcpClient">TcpClient</param>
 /// <param name="message">Client message</param>
 public void SaveMessage(TcpClient tcpClient, string message)
 {
     messageDictionary.AddMessage(tcpClient, message);
     NewMassageEvent?.Invoke(Client, message);
 }