private void HandleMessage(long sessionId, SimpleChat.CMsgChat req) { ChatClient client = null; _clients.TryGetValue(sessionId, out client); SimpleChat.SMsgChat ack = new SimpleChat.SMsgChat(); if (client != null) { ack.sender = client.Account; ack.chatMsg = req.chatMsg; Parallel.ForEach(_clients, (KeyValuePair <long, ChatClient> s) => s.Value.SendObject(SimpleChat.MESSAGE_ID.SMSG_CHAT, ack)); } }
public void SendChat(string msg) { SimpleChat.CMsgChat chat = new SimpleChat.CMsgChat(); chat.chatMsg = msg; SendObject(SimpleChat.MESSAGE_ID.CMSG_CHAT, chat); }