Example #1
0
 private void ListenSocket()
 {
     while (_socket.Connected)
     {
         Message recievedMessage = (Message)_bf.Deserialize(_networkStream);
         lstPanel.Items.Add(recievedMessage.ToString());
     }
 }
Example #2
0
        private void BtnSendMessage_Click(object sender, EventArgs e)
        {
            Message message = new Message
            {
                Content  = txtMessage.Text,
                SendedAt = DateTime.Now,
                Sender   = "Server Message:"
            };

            _bf.Serialize(_networkStream, message);
            _networkStream.Flush();
            lstPanel.Items.Add(message.ToString());
            txtMessage.Clear();
            txtMessage.Focus();
        }