Ejemplo n.º 1
0
        private void TcpProcessServerResponse()
        {
            Packets.Packet serverResponse;
            while ((serverResponse = TcpReadDataFromserver()) != null)
            {
                switch (serverResponse.m_PacketType)
                {
                case Packets.Packet.PacketType.ChatMessage:
                    Packets.ChatMessagePacket chatPacket = serverResponse as Packets.ChatMessagePacket;
                    clientForm.UpdateChatWindow(DecryptString(chatPacket.Message), Colors.Black);
                    break;

                case Packets.Packet.PacketType.PrivateMessage:
                    Packets.PrivateMessagePacket privateMessagePacket = serverResponse as Packets.PrivateMessagePacket;
                    clientForm.UpdateChatWindow(DecryptString(privateMessagePacket.Message), Colors.DeepPink);
                    break;

                case Packets.Packet.PacketType.Disconnect:
                    clientForm.ServerFullLogic();
                    Close();
                    break;

                case Packets.Packet.PacketType.KeyPacket:
                    Packets.KeyPacket keyPacket = serverResponse as Packets.KeyPacket;
                    serverKey = keyPacket.Key;
                    break;

                case Packets.Packet.PacketType.ClientList:
                    Packets.ClientsPacket clientsPacket = serverResponse as Packets.ClientsPacket;
                    clientForm.UpdateClientWindow(clientsPacket.Clients);
                    break;

                case Packets.Packet.PacketType.PictionaryChatMessage:
                    Packets.PictionaryChatMessagePacket pictionaryChatMessagePacket = serverResponse as Packets.PictionaryChatMessagePacket;
                    pictionaryForm.UpdateChatWindow(DecryptString(pictionaryChatMessagePacket.message), Colors.Black);
                    break;

                case Packets.Packet.PacketType.PictionarySetupClient:
                    Packets.PictionarySetupClientPacket pictionarySetupClientPacket = serverResponse as Packets.PictionarySetupClientPacket;
                    SetUpPictionary(pictionarySetupClientPacket.IsDrawer);
                    break;

                case Packets.Packet.PacketType.PictionaryWordToDraw:
                    Packets.PictionaryWordToDrawPacket pictionaryWordToDrawPacket = serverResponse as Packets.PictionaryWordToDrawPacket;
                    pictionaryForm.RecievedWordToDraw(DecryptString(pictionaryWordToDrawPacket.WordToDraw));
                    break;

                case Packets.Packet.PacketType.PictionaryClearCanvas:
                    pictionaryForm.ClearCanvas();
                    break;
                }
            }
        }