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); } }
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); } }
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); }