Esempio n. 1
0
        protected override void OnClientDisconnected(EzClient client)
        {
            Database.UpsertCharacter(client.Character, client.Account.Id);
            Database.UpsertSetting(client.Setting, client.Account.Id);

            if (client.Room != null)
            {
                Room room = client.Room;
                room.Leave(client);

                IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(room);
                Send(room, 10, roomCharacterPacket);

                IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel);
                Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket);
            }

            if (client.Channel != null)
            {
                Channel channel = client.Channel;
                channel.Leave(client);

                IBuffer characterList = LobbyCharacterListPacket.Create(channel);
                Send(channel.GetLobbyClients(), 2, characterList);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        private void OnSessionResponse(Response <Session> result, EzClient client, EzPacket packet)
        {
            _logger.Debug("Client ({0}) entered world (SessionKey: {1})", client.Identity, result.Result.Key);


            client.Session = result.Result;

            Channel channel = Server.GetChannel(client.Mode, client.Session.ChannelId);

            channel.Join(client);

            IBuffer response = EzServer.Buffer.Provide();

            response.WriteByte(1);
            response.WriteByte(0);
            response.WriteByte(7);                              //0A?
            response.WriteByte(0);
            response.WriteByte((byte)client.Mode);              // Mode 0=RubyMix  1=STREET MIX  2=CLUB MIX
            response.WriteByte(0);
            response.WriteByte((byte)client.Session.ChannelId); //1-xCH / 0=1ch 1=2ch 2=3ch 3=4ch
            response.WriteByte(0);
            Send(client, 1, response);

            IBuffer characterList = LobbyCharacterListPacket.Create(channel);

            Send(channel.GetLobbyClients(), 2, characterList);

            IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(channel);

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

            IBuffer applyInventoryPacket = InventoryPacket.ShowInventoryPacket(client.Inventory);

            Send(client, 0x21, applyInventoryPacket);

            IBuffer djPointsPacket = SongPacket.CreateDjPointsPacket();

            Send(client, 0x2B, djPointsPacket); //43

            IBuffer settings = SettingsPacket.Create(client.Setting, client.Mode);

            Send(client, 0x2D, settings); //45
        }
Esempio n. 4
0
        public override int Id => 8; //뒤로 가기

        public override void Handle(EzClient client, EzPacket packet)
        {
            if (client.Player.Playing)
            {
                client.Player.Playing = false;
                client.Player.Ready   = false;
            }
            else
            {
                IBuffer response = EzServer.Buffer.Provide();
                response.WriteByte(1);
                response.WriteByte(0);
                response.WriteByte(7);
                response.WriteByte(0);
                response.WriteByte((byte)client.Session.ChannelId);  //1-xCH / 0=1ch 1=2ch 2=3ch 3=4ch
                Send(client, 5, response);

                if (client.Room != null)
                {
                    Room room = client.Room;
                    room.Leave(client);

                    IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(room);
                    Send(room, 10, roomCharacterPacket);

                    _logger.Debug("Character {0} left room {1}", client.Character.Name, room.Info.Name);
                }
                else
                {
                    _logger.Error("Character {0} left NULL room", client.Character.Name);
                }

                IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel);
                Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket);

                IBuffer characterList = LobbyCharacterListPacket.Create(client.Channel);
                Send(client.Channel.GetLobbyClients(), 2, characterList);
            }
        }
Esempio n. 5
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);
        }