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 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 ERROR_CODE EnterLobby(short lobbyID, ConnectUser user) { var error = ERROR_CODE.NONE; var lobby = LobbyList.Find(x => x.ID == lobbyID); if (lobby == null) { return ERROR_CODE.ENTER_LOBBY_INVALID_LOBBY_ID; } error = lobby.AddUser(user); if (error == ERROR_CODE.NONE) { user.EnterLobby(lobbyID); } return error; }
public void RequestLogin(SFNETPacket packetData, ConnectUser user) { try { var request = JsonEnDecode.Decode<JsonPacketRequestLogin>(packetData.GetData()); // 이미 등록된 유저인가? serial, ID var result = UserManagerRef.AddUser(packetData.SessionID(), request.ID); var response = new JsonPacketResponseLogin() { Result = result }; ServerNetworkRef.Send<JsonPacketResponseLogin>(packetData.SessionID(), PACKET_ID.RESPONSE_LOGIN, response); DevLog.Write(string.Format("[Login] result:{0}, UserID:{1}, SessionID{2}", result.ToString(), request.ID, packetData.SessionID()), LOG_LEVEL.INFO); } catch (Exception) { var response = new JsonPacketResponseLogin() { Result = ERROR_CODE.ERROR }; ServerNetworkRef.Send<JsonPacketResponseLogin>(packetData.SessionID(), PACKET_ID.RESPONSE_LOGIN, response); } }
public ERROR_CODE AddUser(int sessionID, string userID) { if (UserSessionMap.ContainsKey(sessionID)) { return ERROR_CODE.ADD_USER_DUPLICATION_SESSION; } if (UserIDMap.ContainsKey(userID)) { return ERROR_CODE.ADD_USER_DUPLICATION_ID; } var user = new ConnectUser(); user.SetInfo(sessionID, userID); UserSessionMap.Add(sessionID, user); UserIDMap.Add(userID, user); return ERROR_CODE.NONE; }
public void RequestChat(SFNETPacket packetData, ConnectUser user) { if (user == null) { return; } try { var request = JsonEnDecode.Decode<JsonPacketRequestChat>(packetData.GetData()); if (user.LobbyID <= 0) { ResponseErrorLobbyChat(packetData.SessionID(), ERROR_CODE.LOBBY_CHAT_DO_NOT_ENTER_LOBBY); return; } LobbyManagerRef.LobbyChat(user.LobbyID, user.ID, request.Chat); } catch (Exception) { ResponseErrorLobbyChat(packetData.SessionID(), ERROR_CODE.ERROR); } }
public ERROR_CODE AddUser(ConnectUser user) { if (MaxUserCount <= UserList.Count()) { return ERROR_CODE.ENTER_LOBBY_LOBBY_FULL; } UserList.AddLast(user); return ERROR_CODE.NONE; }