Пример #1
0
        private void ReceiveData(TcpClient client)
        {
            NetworkStream ns = client.GetStream();

            byte[] receivedBytes = new byte[Constants.MessageSize];
            int    byte_count;

            while ((byte_count = ns.Read(receivedBytes, 0, receivedBytes.Length)) > 0)
            {
                var messageData = Encoding.UTF8.GetString(receivedBytes, 0, byte_count);
                var message     = ChatMessage.Parse(messageData);

                mMessageHandlers?.Invoke(message);
            }
        }
Пример #2
0
 private void HandleMessage(ChatMessage message)
 {
     OnNewMessage(message);
     mMessageHandlers.Invoke(message);
 }