public void RequestMessages(string Who) { List <Packets.Packet> newChat = new List <Packets.Packet>(); if (Who == "General") { m_View = "General"; Packets.ConversationPackets RequestChat = new Packets.ConversationPackets(Who, newChat); Send(RequestChat); } else { m_View = Who; Packets.RequestForPrivateChat RFPC = new Packets.RequestForPrivateChat(Who); Send(RFPC); Thread.Sleep(500); Packets.ConversationPackets RequestChat = new Packets.ConversationPackets(Who, newChat); Send(RequestChat); } }
public void ProcessServerResponse() { Packets.Packet NewResponse = Read(); switch (NewResponse.m_PacketType) { case Packets.PacketType.ChatMessage: { Packets.ChatMessagePacket CMP = (Packets.ChatMessagePacket)NewResponse; m_ClientForm.UpdateChatWindow(CMP.m_Message); break; } case Packets.PacketType.ErrorMessage: { Packets.ErrorMessagePacket EM = (Packets.ErrorMessagePacket)NewResponse; m_ClientForm.GiveError(EM.m_Message); Console.WriteLine("Error: " + EM.m_Message); Close(); break; } case Packets.PacketType.AnnouncementMessage: { Packets.AnnouncementPacket AP = (Packets.AnnouncementPacket)NewResponse; bool UserName = AP.m_Announcement.Contains(" has joined the chat."); if (UserName) { string UN = AP.m_Announcement.Split()[0]; m_ClientForm.UpdateDropwDown(UN); } m_ClientForm.GiveAnnouncement(AP.m_Announcement); break; } case Packets.PacketType.ClientData: { Packets.ClientData CD = (Packets.ClientData)NewResponse; if (CD.m_ClientNames != null) { for (int i = 0; i < CD.m_ClientNames.Count(); i++) { m_ClientForm.UpdateDropwDown(CD.m_ClientNames[i]); } } break; } case Packets.PacketType.ConversationPacket: { Packets.ConversationPackets CP = (Packets.ConversationPackets)NewResponse; foreach (Packets.Packet message in CP.Conversation) { switch (message.m_PacketType) { case Packets.PacketType.ChatMessage: { Packets.ChatMessagePacket CMP = (Packets.ChatMessagePacket)message; m_ClientForm.UpdateChatWindow(CMP.m_Message); break; } case Packets.PacketType.AnnouncementMessage: { Packets.AnnouncementPacket AP = (Packets.AnnouncementPacket)message; m_ClientForm.GiveAnnouncement(AP.m_Announcement); break; } case Packets.PacketType.PrivateMessage: { Packets.PrivateMessage PM = (Packets.PrivateMessage)message; if (m_View == PM.m_Who || PM.m_Who == m_Nickname) { m_ClientForm.UpdateChatWindow(DecyrptString(PM.m_Message)); } break; } default: { break; } } } break; } case Packets.PacketType.PrivateMessage: { Packets.PrivateMessage PM = (Packets.PrivateMessage)NewResponse; if (m_View == PM.m_Who || PM.m_Who == m_Nickname) { m_ClientForm.UpdateChatWindow(DecyrptString(PM.m_Message)); } break; } case Packets.PacketType.PublicKey: { Packets.PublicKeys PK = (Packets.PublicKeys)NewResponse; m_ServerKey = PK.m_PublicKey; break; } case Packets.PacketType.GameRequest: { Packets.GameRequest GR = (Packets.GameRequest)NewResponse; GameRequestUser = GR.m_From; m_ClientForm.GameInvite(); m_ClientForm.GiveAnnouncement("You have been invited to a game by " + GR.m_From + ". Do you Accept?"); break; } case Packets.PacketType.GameAccepted: { using (m_Game = new Game1()) { m_ManageGameUpdate.Start(); m_Game.Run(); } m_GameUpdate.Dispose(); break; } case Packets.PacketType.RPSSignal: { Packets.RPSSignal S = (Packets.RPSSignal)NewResponse; m_ClientForm.ReadyToRock(S.m_From); break; } default: { break; } } }