private void btnSend_Click(object sender, EventArgs e) { string text = txtChat.Text.Trim(); if (text != string.Empty && receiver != string.Empty && isSignedIn) { User rec = new User() { username = receiver }; ChatterDLL.Message msg = new ChatterDLL.Message() { receiver = rec, data = text, type = ChatterDLL.msgType.chat }; ChatSender.sendMessage(msg); txtChat.Text = string.Empty; } }
public static void StartListener() { ServerConnect._serverSocket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallBack), ServerConnect._serverSocket); if (!frmMain.isSignedIn) { ChatterDLL.Message loginReq = new ChatterDLL.Message(); loginReq.type = msgType.login; loginReq.sender = Chat.localUser; loginReq.receiver = new User() { username = "******" }; ChatSender.sendMessage(loginReq); Chat.addText("Signing in..."); } }