Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
    private void checkDoorOpen()
    {
        Dictionary <string, int> doors = new Dictionary <string, int>(m_doors);

        foreach (string keyId in doors.Keys)
        {
            // 수신한 패킷 데이터에서 캐릭터의 ID와 열쇠의 소유 상태를 보존.
            int doorFlag = m_doors[keyId];

            int mask = ((1 << KEY_MASK) | m_currentPartyMask);

            doorFlag &= mask;
            if (doorFlag == mask)
            {
                // 열쇠를 가지고 전우너 도넛에 올라탔으므로 방 이동 알림.
                MovingRoom room = new MovingRoom();
                room.keyId = keyId;

                string log = "[SERVER] Room move Packet " + "keyId:" + room.keyId;
                Debug.Log(log);

                RoomPacket roomPacket = new RoomPacket(room);

                if (network_ != null)
                {
                    network_.SendReliableToAll <MovingRoom>(roomPacket);
                }

                // 사용이 끝났으므로 클리어.
                m_doors[keyId] = 0;
            }
        }
    }
Ejemplo n.º 3
0
    public void OnReceiveMovingRoomPacket(int node, PacketId id, byte[] data)
    {
#if false
        RoomPacket packet = new RoomPacket(data);
        MovingRoom room   = packet.GetPacket();

        // 방 이동 커맨드 발행.
        PartyControl.getInstance().cmdMoveRoom(room.keyId);
#endif
    }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
    // ================================================================ //
    // 방 이동 알림 패킷 수신 함수.

    public void OnReceiveMovingRoomPacket(int node, PacketId id, byte[] data)
    {
        RoomPacket packet = new RoomPacket(data);
        MovingRoom room   = packet.GetPacket();

        string log = "[CLIENT] Receive moving room packet: " + room.keyId;

        Debug.Log(log);

        // 방 이동 명령 발행.
        cmdMoveRoom(room.keyId);
    }
        public override void Handle(EzClient client, EzPacket packet)
        {
            client.Room.Info.PasswordProtected = packet.Data.ReadInt16() > 0;
            //byte PasswordProtected = packet.Data.ReadByte(); //비밀번호체크
            //packet.Data.ReadByte();
            packet.Data.ReadByte(); //6A
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            client.Room.Info.Password = packet.Data.ReadFixedString(4); // 1비밀번호 4BYTE
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            packet.Data.ReadByte();
            client.Room.Info.MaxPlayer     = packet.Data.ReadByte();                       // 최대 인원
            client.Room.Info.GameType      = (GameType)packet.Data.ReadByte();             // 1
            client.Room.Info.GameGroupType = (GameGroupType)packet.Data.ReadByte();        // 게임 방식
            client.Room.Info.AllowViewer   = packet.Data.ReadByte() > 0;                   // 관전 모드
            client.Room.Info.MaxDifficulty = (DifficultyType)packet.Data.ReadByte();       // 난이도 제한
            packet.Data.ReadByte();                                                        // SELECTED SONG?
            client.Room.Info.Name = packet.Data.ReadFixedString(21, Utils.KoreanEncoding); // 방 이름 21 byte

            IBuffer Result = EzServer.Buffer.Provide();

            Result.WriteByte(0);
            Result.WriteByte(0);
            Result.WriteByte(0);
            Result.WriteByte(0);
            Result.WriteByte(0);
            Result.WriteByte(0);
            Result.WriteByte(0);
            Result.WriteByte(1);                                                      //항상 1로 설정
            Result.WriteByte((byte)client.Room.Info.GameGroupType);                   // 게임 방식
            Result.WriteByte(client.Room.Info.MaxPlayer);                             // 최대 인원
            Result.WriteByte(client.Room.Info.AllowViewer ? (byte)1 : (byte)0);       // 관전모드
            Result.WriteByte((byte)client.Room.Info.MaxDifficulty);                   // 난이도 제한
            Result.WriteByte(0);
            Result.WriteFixedString(client.Room.Info.Name, 20, Utils.KoreanEncoding); // 방 이름 21byte
            Result.WriteByte(0);
            Send(client.Room, 0x11, Result);

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

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

            client.Room.Log(_logger);
        }
Ejemplo n.º 7
0
        public void RemoveIfJoined(Client client)
        {
            if (Clients.Contains(client))
            {
                Clients.Remove(client);
                PacketWriter pw = RoomPacket.ServerMessage(RoomId, client.AccountInfo.Account + " vừa rời khỏi phòng chat.");
                Broadcast(SendHeader.RoomMessage, pw.ToArray());

                //user list update
                pw = new PacketWriter();
                pw.WriteByte((byte)UserOperation.Leave);
                pw.WriteInt(RoomId);
                pw.WriteString(client.AccountInfo.Account);
                Server.Instance.Broadcast(SendHeader.UserListUpdate, pw.ToArray());
            }
        }
    public ServerPacketId GetRoomList(byte[] data)
    {
        Console.WriteLine(tcpPacket.client.RemoteEndPoint.ToString() + " 방목록 조회");

        try
        {
            RoomPacket roomPacket = new RoomPacket(roomManager.GetRoomData());
            msg = roomPacket.GetPacketData();
        }
        catch
        {
            Console.WriteLine("DataHandler::AddPlayerData 에러");
        }

        return(ServerPacketId.RoomList);
    }
Ejemplo n.º 9
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
        }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
0
        private void OnRoomCommandReceived(RoomPacket roomPacket)
        {
            Debug.Log($"Room Command: {roomPacket.RoomCommand} Received");
            switch (roomPacket.RoomCommand)
            {
            case RoomCommand.CREATE_ROOM:
                _runtimeManager.CreateRoom(roomPacket.RoomId);
                _runtimeManager.DisplayRoom();
                break;

            case RoomCommand.CREATE_ROOM_CONFIRMATION:
                break;

            case RoomCommand.JOIN_ROOM:
                JoinRoomRequest(roomPacket.RoomId);
                break;

            case RoomCommand.JOIN_ROOM_CONFIRM:
                _runtimeManager.CreateRoom(roomPacket.RoomId);
                _runtimeManager.DisplayRoom();
                break;

            case RoomCommand.ROOM_UPDATE:
                _runtimeManager.FetchRoom(roomPacket.RoomName, roomPacket.RoomId, roomPacket.PlayersInRoomStruct.PlayersArray);
                break;

            case RoomCommand.LOAD_GAME_SCENE:
                _runtimeManager.LoadGameScene(roomPacket.RoomName, roomPacket.RoomId, roomPacket.PlayersInRoomStruct.PlayersArray);
                break;

            case RoomCommand.LOAD_GAME_SCENE_CONFIRM:
                break;

            default:
                Debug.LogError($"UNHANDLED COMMAND: {roomPacket.RoomCommand}");
                break;
            }
        }
Ejemplo n.º 12
0
        private void RoomPacketReceived(RoomPacket roomPacket, NetPeer peer)
        {
            Player playerSending = _playersManager.GetConnectedPlayer(peer);

            if (playerSending == null)
            {
                return;
            }

            switch (roomPacket.RoomCommand)
            {
            case RoomCommand.CREATE_ROOM:
                _roomsController.CreateRoom(playerSending, roomPacket.RoomName);
                break;

            case RoomCommand.CREATE_ROOM_CONFIRMATION:
                _roomsController.UpdateRoom(_roomsController.Rooms.Find(x => x.RoomId == roomPacket.RoomId));
                break;

            case RoomCommand.JOIN_ROOM:
                _roomsController.AssignPlayerToRoom(playerSending, roomPacket.RoomId);
                break;

            case RoomCommand.JOIN_ROOM_CONFIRM:
                break;

            case RoomCommand.ROOM_UPDATE:
                break;

            case RoomCommand.LOAD_GAME_SCENE_CONFIRM:
                _roomsController.SetPlayerLoaded(playerSending, roomPacket.RoomId);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 13
0
        internal void RecvPacket(byte[] rawData)
        {
            PacketReader pr_raw       = new PacketReader(rawData);
            int          packetLength = pr_raw.ReadInt();
            int          dataType     = pr_raw.ReadByte();

            byte[] data = new byte[packetLength];
            Buffer.BlockCopy(rawData, PacketProcessor.HeaderSize, data, 0, packetLength);

            PacketWriter pw;
            PacketReader pr;

            switch ((RecvHeader)dataType) // PACKET PROCESS HERE!!!
            {
            case RecvHeader.Login:
                pr = new PacketReader(data);
                string account  = pr.ReadString();
                string password = pr.ReadString();
                // Verify here
                AccountInfo = new AccountInfo(account);
                // Reply
                pw = new PacketWriter();
                pw.WriteByte((byte)LoginStatus.Success);
                AccountInfo.Encode(pw);     // Encode AccountInfo object
                Connection.SendData(SendHeader.LoginResult, pw.ToArray());
                Console.WriteLine("{0} đã đăng nhập ({0} / {1})", account, password);
                Server.Instance.SendMessage(account + " vừa đăng nhập.");
                break;

            case RecvHeader.RoomListRequest:
                if (AccountInfo == null)
                {
                    return;                          // Not logged in
                }
                pw = new PacketWriter();
                pw.WriteInt(Server.Instance.Rooms.Count);
                foreach (var room in Server.Instance.Rooms)
                {
                    room.Value.Encode(pw);
                }
                Connection.SendData(SendHeader.RoomList, pw.ToArray());
                break;

            case RecvHeader.CreateRoom:
                pr = new PacketReader(data);
                string name = pr.ReadString();
                string pass = null;
                if (pr.ReadBool())
                {
                    pass = pr.ReadString();
                }
                Room newRoom = new Room(Server.Instance.GenerateRoomId(), name, pass, this);
                Server.Instance.Rooms.Add(newRoom.RoomId, newRoom);
                // Create Result
                pw = new PacketWriter();
                pw.WriteByte((byte)RoomOperation.Success);
                Connection.SendData(SendHeader.CreateRoomResult, pw.ToArray());
                // Update Room!
                pw = new PacketWriter();
                pw.WriteByte((byte)RoomOperation.New);
                newRoom.Encode(pw);
                Server.Instance.Broadcast(SendHeader.RoomListUpdate, pw.ToArray());
                break;

            case RecvHeader.JoinRoomRequest:
                pr = new PacketReader(data);
                int  roomId      = pr.ReadInt();
                bool hasPassword = pr.ReadBool();
                Room rRoom       = null;
                foreach (var room in Server.Instance.Rooms)
                {
                    if (room.Value.RoomId == roomId)
                    {
                        rRoom = room.Value;
                        break;
                    }
                }

                bool isSuccess = false;

                if (rRoom != null)
                {
                    if (hasPassword == (rRoom.Password != null))
                    {
                        string sPass = null;
                        if (hasPassword)
                        {
                            sPass = pr.ReadString();
                        }

                        if ((sPass == null && rRoom.Password == null) || sPass.Equals(rRoom.Password))
                        {
                            isSuccess = true;
                        }
                    }
                }

                pw = new PacketWriter();
                pw.WriteBool(isSuccess);
                if (isSuccess)
                {
                    pw.WriteInt(roomId);
                    pw.WriteString(rRoom.Notice);
                }
                Connection.SendData(SendHeader.JoinRoomResult, pw.ToArray());

                if (isSuccess)
                {
                    // Broadcast to Room
                    pw = RoomPacket.ServerMessage(roomId, AccountInfo.Account + " vừa tham gia phòng chat.");
                    rRoom.Broadcast(SendHeader.RoomMessage, pw.ToArray());

                    //user list update
                    pw = new PacketWriter();
                    pw.WriteByte((byte)UserOperation.New);
                    pw.WriteInt(roomId);
                    //pw.WriteLong(Server.Instance.Clients.Count);
                    pw.WriteString(this.AccountInfo.Account);
                    rRoom.Broadcast(SendHeader.UserListUpdate, pw.ToArray());

                    // Add user to this room
                    rRoom.Clients.Add(this);
                }
                break;

            case RecvHeader.TextChat:
                pr = new PacketReader(data);
                int    desRoomId = pr.ReadInt();
                string message   = pr.ReadString();
                if (Server.Instance.Rooms.ContainsKey(desRoomId))
                {
                    Room cRoom = Server.Instance.Rooms[desRoomId];
                    if (cRoom.Clients.Contains(this))    // Joined this room
                    {
                        // Broadcast chat
                        pw = new PacketWriter();
                        pw.WriteInt(cRoom.RoomId);
                        pw.WriteByte((byte)ChatType.User);
                        pw.WriteString(AccountInfo.Account);
                        pw.WriteString(message);
                        cRoom.Broadcast(this, SendHeader.RoomMessage, pw.ToArray());
                        // Response success
                        pw = new PacketWriter();
                        pw.WriteInt(cRoom.RoomId);
                        pw.WriteByte((byte)ChatType.Success);
                        Connection.SendData(SendHeader.RoomMessage, pw.ToArray());
                    }
                }
                break;

            case RecvHeader.UserListRequest:
                pr = new PacketReader(data);
                int roomID = pr.ReadInt();
                pw = new PacketWriter();
                pw.WriteLong(Server.Instance.Clients.Count);
                pw.WriteInt(roomID);
                foreach (var client in Server.Instance.Clients)
                {
                    pw.WriteString(client.AccountInfo.Account);
                }
                Connection.SendData(SendHeader.UserList, pw.ToArray());
                break;

            case RecvHeader.LeaveRoomRequest:
                pr = new PacketReader(data);
                int roomIDToLeave = pr.ReadInt();
                if (Server.Instance.Rooms.ContainsKey(roomIDToLeave))
                {
                    Room cRoom = Server.Instance.Rooms[roomIDToLeave];
                    if (cRoom.Clients.Contains(this))     // Joined this room
                    {
                        cRoom.RemoveIfJoined(this);
                        pw = new PacketWriter();
                        pw.WriteInt(roomIDToLeave);
                        pw.WriteBool(true);
                        Connection.SendData(SendHeader.LeaveRoomResult, pw.ToArray());
                    }
                }
                break;
            }
        }
Ejemplo n.º 14
0
        public override void Handle(EzClient client, EzPacket packet)
        {
            RoomOptionType roomOption = (RoomOptionType)packet.Data.ReadInt32();

            _logger.Debug("Change Option: {0}", roomOption);
            IBuffer buffer = EzServer.Buffer.Provide();

            switch (roomOption)
            {
            case RoomOptionType.ChangeReady:
            {
                bool ready     = packet.Data.ReadInt32() > 0;
                int  unknown1A = packet.Data.ReadInt32();
                _logger.Debug("ready: {0}", ready);
                _logger.Debug("unknown1A: {0}", unknown1A);     // Slot?
                buffer.WriteByte(0);
                buffer.WriteByte(0);
                buffer.WriteInt32((int)roomOption);
                buffer.WriteInt32(ready ? 1 : 0);
                buffer.WriteInt32(unknown1A);
                client.Player.Ready = ready;
                IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(client.Room);
                Send(client.Room, 10, roomCharacterPacket);
                break;
            }

            case RoomOptionType.ChangeTeam:
            {
                TeamType team      = (TeamType)packet.Data.ReadInt32();
                int      unknown0B = packet.Data.ReadInt32();
                _logger.Debug("unknown0B: {0}", unknown0B);
                buffer.WriteByte(0);
                buffer.WriteByte(0);
                buffer.WriteInt32((int)roomOption);
                buffer.WriteInt32((int)team);
                buffer.WriteInt32(unknown0B);
                client.Player.Team = team;
                IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(client.Room);
                Send(client.Room, 10, roomCharacterPacket);
                break;
            }

            case RoomOptionType.ChangeFade:
                client.Room.Info.FadeEffect = (FadeEffectType)packet.Data.ReadInt32();
                int unknown0C = packet.Data.ReadInt32();
                _logger.Debug("unknown0C: {0}", unknown0C);
                buffer.WriteByte(0);
                buffer.WriteByte(0);
                buffer.WriteInt32((int)roomOption);
                buffer.WriteInt32((int)client.Room.Info.FadeEffect);
                buffer.WriteInt32(unknown0C);
                break;

            case RoomOptionType.ChangeNote:
                client.Room.Info.NoteEffect = (NoteEffectType)packet.Data.ReadInt32();
                int unknown0D = packet.Data.ReadInt32();
                _logger.Debug("unknown0D: {0}", unknown0D);
                buffer.WriteByte(0);
                buffer.WriteByte(0);
                buffer.WriteInt32((int)roomOption);
                buffer.WriteInt32((int)client.Room.Info.NoteEffect);
                buffer.WriteInt32(unknown0D);
                break;

            case RoomOptionType.ChangeSongAndDifficulty:
                client.Room.Info.RandomSong   = false;
                client.Room.Info.SelectedSong = packet.Data.ReadInt32();
                client.Room.Info.Difficulty   = (DifficultyType)packet.Data.ReadInt32();
                buffer.WriteByte(0);
                buffer.WriteByte(0);
                buffer.WriteInt32((int)roomOption);
                buffer.WriteInt32((int)client.Room.Info.SelectedSong);
                buffer.WriteInt32((int)client.Room.Info.Difficulty);
                break;

            case RoomOptionType.StartGame:
                int unknown0E = packet.Data.ReadInt32();
                int unknown1E = packet.Data.ReadInt32();
                _logger.Debug("unknown0E: {0}", unknown0E);
                _logger.Debug("unknown1E: {0}", unknown1E);
                buffer.WriteByte(0);
                buffer.WriteByte(0);
                buffer.WriteInt32((int)roomOption);
                buffer.WriteInt32(unknown0E);
                buffer.WriteInt32(unknown1E);
                break;

            case RoomOptionType.ChangeRandom:
                client.Room.Info.RandomSong   = true;
                client.Room.Info.SelectedSong = packet.Data.ReadInt32();
                client.Room.Info.Difficulty   = (DifficultyType)packet.Data.ReadInt32();
                buffer.WriteByte(0);
                buffer.WriteByte(0);
                buffer.WriteInt32((int)roomOption);
                buffer.WriteInt32((int)client.Room.Info.SelectedSong);
                buffer.WriteInt32((int)client.Room.Info.Difficulty);
                break;

            case RoomOptionType.ViewVideo:
                // TODO deduct 1000 coins.
                break;
            }

            Send(client.Room, 16, buffer);

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

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

            client.Room.Log(_logger);
        }
Ejemplo n.º 15
0
	// ================================================================ //
	// 방 이동 알림 패킷 수신 함수.

	public void OnReceiveMovingRoomPacket(int node, PacketId id, byte[] data)
	{
		RoomPacket packet = new RoomPacket(data);
		MovingRoom room = packet.GetPacket();

		string log = "[CLIENT] Receive moving room packet: " + room.keyId;
		Debug.Log(log);

		// 방 이동 명령 발행.
		cmdMoveRoom(room.keyId);
	}
Ejemplo n.º 16
0
 private void HandleRoomCommand(RoomPacket roomPacket, NetPeer sender)
 {
     NetHub.RoomCommandReceived.Invoke(roomPacket);
 }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
	private void checkDoorOpen()
	{
		Dictionary<string, int> doors = new Dictionary<string, int>(m_doors);

		foreach (string keyId in doors.Keys) {

			// 수신한 패킷 데이터에서 캐릭터의 ID와 열쇠의 소유 상태를 보존.
			int doorFlag = m_doors[keyId];

			int mask = ((1 << KEY_MASK) | m_currentPartyMask);

			doorFlag &= mask;
			if (doorFlag == mask) {
				// 열쇠를 가지고 전우너 도넛에 올라탔으므로 방 이동 알림.
				MovingRoom room = new MovingRoom();
				room.keyId = keyId;
	
				string log = "[SERVER] Room move Packet " + "keyId:" + room.keyId;
				Debug.Log(log);

				RoomPacket roomPacket = new RoomPacket(room);
				
				if (network_ != null) {
					network_.SendReliableToAll<MovingRoom>(roomPacket);
				}
				
				// 사용이 끝났으므로 클리어.
				m_doors[keyId] = 0;
			}
		}
	}