Ejemplo n.º 1
0
        public override void DoActions(ref Client client)
        {
            switch (PacketType)
            {
            case PacketType.c_InitiateGame:

                //
                // Only allow the room host to start the game.
                //

                if (client.Room.GetHostAddress() == client.UserInfo.EmailAddress)
                {
                    MessageSender.BroadcastMessage(client.Room.Members, PacketType.s_BeginGameInitialization, null);
                }
                break;

            case PacketType.c_Dump:
                MessageSender.BroadcastMessage(client.Room.Members, PacketType.s_Dump, client.UserInfo, client);
                break;

            case PacketType.c_Peel:
                MessageSender.BroadcastMessage(client.Room.Members, PacketType.s_Peel, client.UserInfo, client);
                break;

            case PacketType.c_Victory:
                MessageSender.BroadcastMessage(client.Room.Members, PacketType.s_GameOver, client.UserInfo, client);
                break;

            default:
                Trace.WriteLine(string.Format("[GamePacketHandler.DoActions] - " +
                                              "Invalid packet type for this PacketHandler = {0}", PacketType.ToString()));
                break;
            }
        }
Ejemplo n.º 2
0
        public override void DoActions(ref Client client)
        {
            var    clientManager = ClientManager.GetInstance();
            var    roomManager   = RoomManager.GetInstance();
            Friend friend;

            switch (PacketType)
            {
            case PacketType.c_LogIn:
                friend = Data as Friend;

                if (null != friend)
                {
                    ProcessLogInPacket(client, friend);
                }
                break;

            case PacketType.c_LogOut:
                clientManager.RemoveClient(client);
                break;

            case PacketType.c_JoinRoom:
                friend = Data as Friend;

                if (null != friend)
                {
                    client = ProcessJoinRoomPacket(client, friend);
                }
                break;

            case PacketType.c_LeaveRoom:
                roomManager.RemoveMemberfromRoom(client.Room.Host, client);


                //
                //  Add the user to a newly createad room.
                //

                var newRoom = roomManager.CreateNewRoom(client);

                client.Room = newRoom;

                break;

            case PacketType.c_InitiateGame:

                //
                // Only allow the room host to initiate a game.
                //

                if (client.Room.GetHostAddress() == client.UserInfo.EmailAddress)
                {
                    MessageSender.BroadcastMessage(
                        client.Room.Members,
                        PacketType.s_BeginGameInitialization,
                        null,
                        client);
                }

                break;

            case PacketType.c_Chat:
                var arguments = Data as ChatMessage;

                if (arguments != null)
                {
                    MessageSender.BroadcastMessage(client.Room.Members, PacketType.s_Chat, arguments, client);
                }
                break;

            case PacketType.c_ReadyForGameStart:
                client.Room.SignalClientIsReadyForGame(client);
                break;

            default:
                Trace.WriteLine(string.Format("[RoomPacketHandler.DoActions] - " +
                                              "Invalid packet type for this PacketHandler = {0}", PacketType.ToString()));
                break;
            }
        }