public override void Handle(EzClient client, EzPacket packet)
        {
            if (client.Room == null)
            {
                RoomInfo info = new RoomInfo();
                info.PasswordProtected = packet.Data.ReadInt16() > 0;
                packet.Data.ReadInt32(); // 69~6A
                info.Password = packet.Data.ReadFixedString(4, Utils.KoreanEncoding);
                packet.Data.ReadInt32();
                packet.Data.ReadInt32();
                info.MaxPlayer     = packet.Data.ReadByte();
                info.GameType      = (GameType)packet.Data.ReadByte();      // SinglePlayer / MultiPlayer
                info.GameGroupType = (GameGroupType)packet.Data.ReadByte(); // Individual / Team
                info.AllowViewer   = packet.Data.ReadByte() > 0;
                info.MaxDifficulty = (DifficultyType)packet.Data.ReadByte();
                info.SelectedSong  = packet.Data.ReadInt32(Endianness.Big);
                info.Name          = packet.Data.ReadFixedString(20, Utils.KoreanEncoding);

                Room room = client.Channel.CreateRoom(info, client);

                IBuffer openRoomPacket = RoomPacket.CreateOpenRoomPacket(client.Room, client);
                Send(client, 9, openRoomPacket);

                IBuffer characterList = LobbyCharacterListPacket.Create(client.Channel);
                Send(client.Channel.GetLobbyClients(), 2, characterList);

                _logger.Debug("Opened Room");
            }
            else
            {
                //HEX:05-00-39-00-00-00-00-00-00-67-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-01-00-00-00-0A-
                //00-00-00-0E-C3-CA-BA-B8-B8-B8-20-BF-C0-BC-BC-BF-E4-21-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

                //HEX:05-00-39-00-00-00-00-00-00-67-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-01-00-00-00-0A-
                //00-00-00-0E-C3-CA-BA-B8-B8-B8-20-BF-C0-BC-BC-BF-E4-21-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00


                IBuffer joinRoomPacket = RoomPacket.CreateJoinRoomPacket(client.Room, client);

                Send(client, 8, joinRoomPacket);

                _logger.Debug("Joined Room");
            }

            IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(client.Room);

            Send(client, 10, roomCharacterPacket);

            IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel);

            Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket);

            client.Room.Log(_logger);
        }
Exemple #2
0
        // 06-00-15-00-00-00-00-     00-00- 00-6A- 00-00-01- 00-00-00-00- 00-00-00-00-00-00-00-00-01-00
        // 6A ?
        // 01 Room number

        //HEX:06-00-15-00-00-00-00-  00-00- 00-67- 00-00-03 -00-00-00-00 -00-00-00-00-00-00-00-00-01-00

        //ASCII:.  .  .  .  .  .  .  .  .  .  g  .  .  .      s  d  d  d  .  .  .  .  .  .  .  .  .  .
        //HEX:06-00-15-00-00-00-00-  00- 01- 00-67 -00-00-00- 73-64-64-64- 00-00-00-00-00-00-00-00-01-00

        //    06-00-15-00-00-00-00- 00-01-00-67- 00-00-00-71-77-65-00-00-00-00-00-00-00-00-00-01-00
        //    06-00-15-00-00-00-00- 00-00-00-67- 00-00-01-00-00-00-00-00-00-00-00-00-00-00-00-01-00



        // 12 = exit room TODO
        // 11 = join room


        public override void Handle(EzClient client, EzPacket packet)
        {
            byte   quickStart        = packet.Data.ReadByte();
            byte   passwordProtected = packet.Data.ReadByte();
            byte   unknown0          = packet.Data.ReadByte();
            byte   channel           = packet.Data.ReadByte(); // Channel + 100, 0 Indexed
            byte   unknown1          = packet.Data.ReadByte();
            byte   unknown2          = packet.Data.ReadByte();
            byte   roomNumber        = packet.Data.ReadByte();
            string password          = packet.Data.ReadFixedString(4, Utils.KoreanEncoding);


            _logger.Debug("Channel: {0}, Password {1}, Room#:{2}, QuickStart:{3}, PwProtected:{4}",
                          channel - 100 + 1, password, roomNumber, quickStart, passwordProtected);

            Room room;

            if (quickStart > 0)
            {
                room = client.Channel.GetQuickRoom();
                if (room == null)
                {
                    _logger.Debug("No QuickStart Room found");
                    IBuffer joinErrorPacket = RoomPacket.CreateJoinErrorPacket();
                    Send(client, 8, joinErrorPacket);
                    return;
                }
            }
            else
            {
                room = client.Channel.GetRoom(roomNumber);
            }

            if (room == null)
            {
                _logger.Error("Invalid room");
                IBuffer joinErrorPacket = RoomPacket.CreateJoinErrorPacket();
                Send(client, 8, joinErrorPacket);
                return;
            }

            if (passwordProtected > 0 && room.Info.Password != password)
            {
                _logger.Error("Invalid password ({0}) for room with password ({1})", password, room.Info.Password);
                IBuffer joinErrorPacket = RoomPacket.CreateJoinErrorPacket();
                Send(client, 8, joinErrorPacket);
                return;
            }

            room.Join(client);

            IBuffer joinRoomPacket = RoomPacket.CreateJoinRoomPacket(room, client);

            Send(client, 8, joinRoomPacket);

            IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(room);

            Send(room, 10, roomCharacterPacket);

            IBuffer announceJoinPacket = RoomPacket.AnnounceJoin(client);

            Send(room, 11, announceJoinPacket);

            IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel);

            Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket);

            IBuffer characterList = LobbyCharacterListPacket.Create(client.Channel);

            Send(client.Channel.GetLobbyClients(), 2, characterList);

            _logger.Debug("Character {0} joined room {1}", client.Character.Name, room.Info.Name);
        }