Ejemplo n.º 1
0
        public void RequestLobbyEnter(ServerPacketData packetData)
        {
            var sessionID = packetData.SessionID;

            LobbyServer.MainLogger.Debug("RequestLobbyEnter");

            try
            {
                var user = UserMgr.GetUserByNetSessionID(sessionID);

                if (user == null || user.IsAuthenticated == false)
                {
                    ResponseLobbyEnterToClient(sessionID, ERROR_CODE.LOBBY_ENTER_INVALID_USER);
                    return;
                }

                if (user.IsStateLobby())
                {
                    ResponseLobbyEnterToClient(sessionID, ERROR_CODE.LOBBY_ENTER_INVALID_STATE);
                    return;
                }

                var reqData = new LobbyEnterReqPacket();
                reqData.Decode(packetData.BodyData);

                var lobby = GetLobby(reqData.LobbyNumber);
                if (lobby == null)
                {
                    ResponseLobbyEnterToClient(sessionID, ERROR_CODE.LOBBY_ENTER_INVALID_ROOM_NUMBER);
                    return;
                }

                if (lobby.AddUser(user.ID, sessionID) == false)
                {
                    ResponseLobbyEnterToClient(sessionID, ERROR_CODE.LOBBY_ENTER_FAIL_ADD_USER);
                    return;
                }


                user.EnteredLobby(reqData.LobbyNumber);

                ResponseLobbyEnterToClient(sessionID, ERROR_CODE.NONE);

                LobbyServer.MainLogger.Debug("RequestLobbyEnter - Success");
            }
            catch (Exception ex)
            {
                LobbyServer.MainLogger.Error(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public void LobbyEnterRequest(int roomNumber)
        {
            var requestPkt = new LobbyEnterReqPacket()
            {
                LobbyNumber = roomNumber,
            };

            //아래는 requestSend부분
            if (CheckNetworkConnected() == false)
            {
                return;
            }

            try
            {
                PostSendPacket(CL_PACKET_ID.REQ_LOBBY_ENTER, requestPkt.ToBytes());
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
            }
        }