public void SendMessageToAll(string nickname, string message) { if (!string.IsNullOrEmpty(nickname) && !string.IsNullOrEmpty(message)) { PacketInfo packetInfoMessage = new PacketInfo("Message"); MessageInfo messageInfo = new MessageInfo(message); messageInfo.FromUser = new UserInfo(nickname); packetInfoMessage.Data = messageInfo; SendToAll(packetInfoMessage); } }
public void SendMessage(string message, string toUser, Color color) { if (!string.IsNullOrEmpty(message)) { PacketInfo packetInfo = new PacketInfo("Message"); MessageInfo messageInfo = new MessageInfo(message); if (!string.IsNullOrEmpty(toUser)) messageInfo.ToUser = new UserInfo(toUser); messageInfo.TextColor = color; packetInfo.Data = messageInfo; client.SendPacket(packetInfo); } }
protected void OnMessageReceived(MessageInfo messageInfo) { if (MessageReceived != null) { MessageReceived(messageInfo); } }
private void client_MessageReceived(MessageInfo messageInfo) { string user; if (messageInfo.ToUser != null && !string.IsNullOrEmpty(messageInfo.ToUser.Nickname)) { user = string.Format("{0} > {1}", messageInfo.FromUser.Nickname, messageInfo.ToUser.Nickname); } else { user = messageInfo.FromUser.Nickname; } AddClientMessage(user, messageInfo.Text, messageInfo.TextColor); }