private void sendMsg() { if (textBox1.Text.Length == 0) { return; } if (isHost == true) { messageHolder toSend = new messageHolder(host.name + ": " + textBox1.Text); ChatLog.Items.Add(host.name + ": " + textBox1.Text); List <ConnectionInfo> l = NetworkComms.AllConnectionInfo(); foreach (ConnectionInfo i in l) { TCPConnection.GetConnection(i).SendObject("Message", toSend); } } else { messageHolder toSend = new messageHolder(cinfo.name + ": " + textBox1.Text); ChatLog.Items.Add(cinfo.name + ": " + textBox1.Text); newTCPConn.SendObject("Message", toSend); } textBox1.Clear(); }
private void addMessage(PacketHeader packetHeader, Connection connection, messageHolder incomingObject) { ChatLog.Invoke(new MethodInvoker(delegate() { ChatLog.Items.Add(incomingObject.message); })); foreach (clientInfoServ cinfo in clientList) { Connection conn = cinfo.conn; if (conn == null || conn.Equals(conn)) { continue; } conn.SendObject("Message", incomingObject); } }
private void NotifyServer(Connection conn, string v) { ChatLog.Invoke(new MethodInvoker(delegate() { ChatLog.Items.Add(v); })); messageHolder toSend = new messageHolder(v); foreach (clientInfoServ cinfo in clientList) { Connection connection = cinfo.conn; if (connection == null || connection.Equals(conn)) { continue; } connection.SendObject("Message", toSend); } }