Beispiel #1
0
        public void RequestLeaveLobby(SFNETPacket packetData, ConnectUser user)
        {
            if (user == null)
            {
                return;
            }

            try
            {
                var request = JsonEnDecode.Decode <JsonPacketRequestLeaveLobby>(packetData.GetData());

                if (user.LobbyID <= 0 || request.LobbyID != user.LobbyID)
                {
                    ResponseLeaveLobby(packetData.SessionID(), ERROR_CODE.LEAVE_LOBBY_DO_NOT_ENTER_LOBBY, 0);
                    return;
                }

                var result = LobbyManagerRef.LeaveLobby(user.LobbyID, user.ID);
                if (result != ERROR_CODE.NONE)
                {
                    ResponseLeaveLobby(packetData.SessionID(), result, 0);
                    return;
                }

                user.LeaveLobby();

                ResponseLeaveLobby(packetData.SessionID(), ERROR_CODE.NONE, 0);

                InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID));
            }
            catch (Exception)
            {
                ResponseLeaveLobby(packetData.SessionID(), ERROR_CODE.ERROR, 0);
            }
        }
Beispiel #2
0
        void ProcessInnerMessage()
        {
            while (true)
            {
                InnerMsg msg;

                if (InnerMessageQueue.GetMsg(out msg))
                {
                    switch (msg.Type)
                    {
                    case InnerMsgType.CURRENT_LOBBY_USER_COUNT:
                    {
                        var tokens = msg.Value1.Split("_");

                        int iItemNum = listViewLobbyInfo.Items.Count;

                        for (int i = 0; i < iItemNum; ++i)
                        {
                            if (tokens[0] == listViewLobbyInfo.Items[i].SubItems[0].Text)
                            {
                                listViewLobbyInfo.Items[i].SubItems[1].Text = tokens[1];
                                listViewLobbyInfo.Refresh();
                                return;
                            }
                        }
                    }
                    break;
                    }
                }
                else
                {
                    break;
                }
            }
        }
Beispiel #3
0
        public void RequestEnterLobby(SFNETPacket packetData, ConnectUser user)
        {
            if (user == null)
            {
                return;
            }

            try
            {
                var request = JsonEnDecode.Decode <JsonPacketRequestEnterLobby>(packetData.GetData());

                // 이미 로비에 들어가 있는가?
                if (user.LobbyID != 0)
                {
                    ResponseEnterLobby(packetData.SessionID(), ERROR_CODE.ENTER_LOBBY_ALREADY_LOBBY, 0);
                    return;
                }

                // 로비에 추가
                var error = LobbyManagerRef.EnterLobby(request.LobbyID, user);
                if (error != ERROR_CODE.NONE)
                {
                    ResponseEnterLobby(packetData.SessionID(), error, 0);
                    return;
                }

                ResponseEnterLobby(packetData.SessionID(), ERROR_CODE.NONE, request.LobbyID);

                InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID));
            }
            catch (Exception)
            {
                ResponseEnterLobby(packetData.SessionID(), ERROR_CODE.ERROR, 0);
            }
        }
Beispiel #4
0
        public void ClientDisConnect(int sessionID)
        {
            var user = UserManager.GetUser(sessionID);

            if (user != null && user.LobbyID > 0)
            {
                LobbyMgr.LeaveLobby(user.LobbyID, user.ID);
                InnerMessageQueue.CurrentLobbyUserCount(user.LobbyID, LobbyMgr.LobbyCurrentUserCount(user.LobbyID));
            }

            UserManager.RemoveUser(sessionID);
        }