Example #1
0
 public void printMessageChat(String message)
 {
     ChatRichTextForm.Invoke((MethodInvoker) delegate
     {
         ChatRichTextForm.AppendText(message + "\n");
     });
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String msg = MessageRichTextBox.Text;

            MessageRichTextBox.Clear();
            ChatRichTextForm.AppendText(userChat.getUserInfo().getName() + ":" + msg + "\n");
            sendMsg(new TcpMessage(TcpMessage.TypeMsg.Msg, msg, userChat.getUserInfo().getName()));
        }
Example #3
0
 public ChatForm(bool isServer = false, UserInfo userInfo = null)
 {
     InitializeComponent();
     this.isServer = isServer;
     if (isServer)
     {
         socketServer = new SocketServer(8080, this);
         socketServer.start();
         ChatRichTextForm.AppendText("Server start\n");
         userChat = new UserChat(new UserInfo("server"), this);
     }
     else
     {
         userChat = new UserChat(userInfo, this);
         userChat.sendMessageObject(new TcpMessage(TcpMessage.TypeMsg.Login, "", userInfo.getName()));
         //userChat.sendMessage(userInfo.getName());
         Thread backgroundThread = new Thread(new ThreadStart(userChat.listenNewMessage));
         backgroundThread.Start();
     }
 }