public void DBResponseLogin(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } try { var serializer = MessagePackSerializer.Get<DB.ResponseLogin>(); var request = serializer.UnpackSingleObject(packet.GetData()); if (request.Result == ERROR_CODE.NONE) { UserManagerRef.유저_인증_완료(user); DevLog.Write(string.Format("DB 인증 성공. ID:{0}", request.UserID), LOG_LEVEL.DEBUG); } else { user.BasicState(); DevLog.Write(string.Format("DB 인증 실패. ID:{0}, Result:{1}", request.UserID, request.Result.ToString()), LOG_LEVEL.DEBUG); } var jsonData = new JsonPacketResponseLogin() { Result = request.Result }; ServerNetworkRef.Send<JsonPacketResponseLogin>(packet.SessionID(), PACKET_ID.RESPONSE_LOGIN, jsonData); } catch (Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.DEBUG); } }
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 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 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 InnerNotifyEnterLobby(SFNETPacket packet) { var notify = JsonEnDecode.Decode<CSCommonLib.JsonPacketInnerNotifyEnterLobby>(packet.GetData()); var user = UserManagerRef.GetUser(notify.UserID); if (user == null) { var jsonData = new JsonPacketInnerRollBackEnterLobby() { LobbyID = notify.LobbyID, UserID = notify.UserID }; var bodyData = CGSFNETCommon.JsonEnDecode.Encode<JsonPacketInnerRollBackEnterLobby>(jsonData); var InnerPacket = new CgsfNET64Lib.SFNETPacket(); InnerPacket.SetData(-1, (ushort)PACKET_ID.INNER_ROLL_BACK_ENTER_LOBBY, bodyData); RelayPacketPacketProcess.RelayPacket(notify.LobbyID, InnerPacket); return; } if (notify.Result == ERROR_CODE.NONE) { user.SetLobby(notify.LobbyID); } else { user.SetLobby(0); } var response = new JsonPacketResponseEnterLobby() { Result = notify.Result, LobbyID = notify.LobbyID }; ServerNetworkRef.Send<JsonPacketResponseEnterLobby>(user.SessionID, PACKET_ID.RESPONSE_ENTER_LOBBY, response); }
public void RequestChat(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode<JsonPacketRequestChat>(packetData.GetData()); LobbyManagerRef.LobbyChat(request.LobbyID, request.UserID, request.Chat); } catch { } }
public void RequestChat(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode <JsonPacketRequestChat>(packetData.GetData()); LobbyManagerRef.LobbyChat(request.LobbyID, request.UserID, request.Chat); } catch { } }
public void ResponseRegistServer(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode<JsonPacketResponseReqistServer>(packetData.GetData()); DevLog.Write(string.Format("result:{0}, ServerName:{1}, SessionID: {2}", request.Result.ToString(), request.ServerName, packetData.SessionID()), LOG_LEVEL.INFO); } catch { } }
public void ResponseRegistServer(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode <JsonPacketResponseReqistServer>(packetData.GetData()); DevLog.Write(string.Format("result:{0}, ServerName:{1}, SessionID: {2}", request.Result.ToString(), request.ServerName, packetData.SessionID()), LOG_LEVEL.INFO); } catch { } }
public void InnerRoolBackEnterLobby(SFNETPacket packet) { try { var request = JsonEnDecode.Decode<JsonPacketInnerRollBackEnterLobby>(packet.GetData()); // 로비에 추가 var error = LobbyManagerRef.LeaveLobby(request.LobbyID, request.UserID); if (error == ERROR_CODE.NONE) { InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID)); } } catch { } }
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 { } }
public void RequestRegistServer(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode<JsonPacketRequestReqistServer>(packetData.GetData()); // 이미 등록된 유저인가? serial, ID var result = ServerManagerRef.AddServer(packetData.SessionID(), request.ServerName); var response = new JsonPacketResponseReqistServer() { Result = result, ServerName = "GameServer" }; ServerNetworkRef.Send<JsonPacketResponseReqistServer>(packetData.SessionID(), PACKET_ID.RESPONSE_REGIST_SERVER, response); DevLog.Write(string.Format("result:{0}, ServerName:{1}, SessionID: {2}", result.ToString(), request.ServerName, packetData.SessionID()), LOG_LEVEL.INFO); CGSFNETCommon.FileLogger.Info(string.Format("result:{0}, ServerName:{1}, SessionID: {2}", result.ToString(), request.ServerName, packetData.SessionID())); } catch { } }
public void RequestEnterLobby(SFNETPacket packet) { try { var request = JsonEnDecode.Decode<JsonPacketRequestEnterLobby>(packet.GetData()); // 로비에 추가 var error = LobbyManagerRef.EnterLobby(request.LobbyID, packet.SessionID(), request.UserID); if (error == ERROR_CODE.NONE) { InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID)); } ResponseEnterLobby(error, request.LobbyID, request.UserID); } catch { } }
public void ProcessPacket(SFNETPacket packet) { try { var packetID = packet.PacketID(); if (PacketHandlerMap.ContainsKey(packetID)) { PacketHandlerMap[packetID](packet); } else { System.Diagnostics.Debug.WriteLine("세션 번호 {0}, PacketID {1}, 받은 데이터 크기: {2}", packet.SessionID(), packetID, packet.GetData().Length); } } catch (Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.ERROR); } }
public void RequestEnterLobby(SFNETPacket packet) { try { var request = JsonEnDecode.Decode <JsonPacketRequestEnterLobby>(packet.GetData()); // 로비에 추가 var error = LobbyManagerRef.EnterLobby(request.LobbyID, packet.SessionID(), request.UserID); if (error == ERROR_CODE.NONE) { InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID)); } ResponseEnterLobby(error, request.LobbyID, request.UserID); } catch { } }
public void RequestLeaveLobby(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode <JsonPacketRequestLeaveLobby>(packetData.GetData()); var result = LobbyManagerRef.LeaveLobby(request.LobbyID, request.UserID); if (packetData.SessionID() >= 0) { ResponseLeaveLobby(result, request.LobbyID, request.UserID); } if (result == ERROR_CODE.NONE) { InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID)); } } catch { } }
public void RequestRegistServer(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode <JsonPacketRequestReqistServer>(packetData.GetData()); // 이미 등록된 유저인가? serial, ID var result = ServerManagerRef.AddServer(packetData.SessionID(), request.ServerName); var response = new JsonPacketResponseReqistServer() { Result = result, ServerName = "GameServer" }; ServerNetworkRef.Send <JsonPacketResponseReqistServer>(packetData.SessionID(), PACKET_ID.RESPONSE_REGIST_SERVER, response); DevLog.Write(string.Format("result:{0}, ServerName:{1}, SessionID: {2}", result.ToString(), request.ServerName, packetData.SessionID()), LOG_LEVEL.INFO); CGSFNETCommon.FileLogger.Info(string.Format("result:{0}, ServerName:{1}, SessionID: {2}", result.ToString(), request.ServerName, packetData.SessionID())); } catch { } }
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 void DBResponseLogin(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } try { var serializer = MessagePackSerializer.Get <DB.ResponseLogin>(); var request = serializer.UnpackSingleObject(packet.GetData()); if (request.Result == ERROR_CODE.NONE) { UserManagerRef.저_인증_완료(user); DevLog.Write(string.Format("DB 인증 성공. ID:{0}", request.UserID), LOG_LEVEL.DEBUG); } else { user.BasicState(); DevLog.Write(string.Format("DB 인증 실패. ID:{0}, Result:{1}", request.UserID, request.Result.ToString()), LOG_LEVEL.DEBUG); } var jsonData = new JsonPacketResponseLogin() { Result = request.Result }; ServerNetworkRef.Send <JsonPacketResponseLogin>(packet.SessionID(), PACKET_ID.RESPONSE_LOGIN, jsonData); } catch (Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.DEBUG); } }
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 void RequestEnterLobby(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } try { var request = JsonEnDecode.Decode <CSCommonLib.JsonPacketRequestEnterLobby>(packet.GetData()); if (user.CurrentState != CONNECT_USER_STATE.ATUH_COMPLETE || user.UserID != request.UserID) { return; } user.TryEnterLobby(); RelayPacketPacketProcess.RelayPacket(request.LobbyID, packet); } catch (Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.DEBUG); } }
public void InnerNotifyLeaveLobby(SFNETPacket packet) { var notify = JsonEnDecode.Decode <CSCommonLib.JsonPacketInnerNotifyLeaveLobby>(packet.GetData()); var user = UserManagerRef.GetUser(notify.UserID); if (user == null) { return; } user.SetLobby(0); var response = new JsonPacketResponseLeaveLobby() { Result = notify.Result }; ServerNetworkRef.Send <JsonPacketResponseLeaveLobby>(user.SessionID, PACKET_ID.RESPONSE_LEAVE_LOBBY, response); }
public void RequestLogin(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } try { if (user.CurrentState != CONNECT_USER_STATE.NONE) { return; } var request = JsonEnDecode.Decode <CSCommonLib.JsonPacketRequestLogin>(packet.GetData()); // DB 작업 의뢰한다. var dbReqLogin = new DB.RequestLogin() { PW = request.PW }; var serializer = MessagePackSerializer.Get <DB.RequestLogin>(); var jobDatas = serializer.PackSingleObject(dbReqLogin); InsertDBRequest(PACKET_ID.DB_REQUEST_LOGIN, packet.SessionID(), request.ID, jobDatas); DevLog.Write("DB에 로그인 요청 보냄", LOG_LEVEL.DEBUG); } catch (Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.DEBUG); } }
public void InnerRoolBackEnterLobby(SFNETPacket packet) { try { var request = JsonEnDecode.Decode <JsonPacketInnerRollBackEnterLobby>(packet.GetData()); // 로비에 추가 var error = LobbyManagerRef.LeaveLobby(request.LobbyID, request.UserID); if (error == ERROR_CODE.NONE) { InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID)); } } catch { } }
void Process() { SFNETPacket packet = null; while (IsThreadRunning) { try { if (PacketQueue.TryDequeue(out packet) == false) { System.Threading.Thread.Sleep(1); continue; } var packetID = packet.PacketID(); if (PacketHandlerMap.ContainsKey(packetID)) { PacketHandlerMap[packetID](packet); } else { System.Diagnostics.Debug.WriteLine("세션 번호 {0}, PacketID {1}, 받은 데이터 크기: {2}", packet.SessionID(), packetID, packet.GetData().Length); } } catch (Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.ERROR); } } }
public void RequestLeaveLobby(SFNETPacket packetData) { try { var request = JsonEnDecode.Decode<JsonPacketRequestLeaveLobby>(packetData.GetData()); var result = LobbyManagerRef.LeaveLobby(request.LobbyID, request.UserID); if (packetData.SessionID() >= 0) { ResponseLeaveLobby(result, request.LobbyID, request.UserID); } if (result == ERROR_CODE.NONE) { InnerMessageQueue.CurrentLobbyUserCount(request.LobbyID, LobbyManagerRef.LobbyCurrentUserCount(request.LobbyID)); } } catch { } }
public void RequestEnterLobby(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } try { var request = JsonEnDecode.Decode<CSCommonLib.JsonPacketRequestEnterLobby>(packet.GetData()); if (user.CurrentState != CONNECT_USER_STATE.ATUH_COMPLETE || user.UserID != request.UserID) { return; } user.TryEnterLobby(); RelayPacketPacketProcess.RelayPacket(request.LobbyID, packet); } catch (Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.DEBUG); } }
public void RequestLogin(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } try { if (user.CurrentState != CONNECT_USER_STATE.NONE) { return; } var request = JsonEnDecode.Decode<CSCommonLib.JsonPacketRequestLogin>(packet.GetData()); // DB 작업 의뢰한다. var dbReqLogin = new DB.RequestLogin() { PW = request.PW }; var serializer = MessagePackSerializer.Get<DB.RequestLogin>(); var jobDatas = serializer.PackSingleObject(dbReqLogin); InsertDBRequest(PACKET_ID.DB_REQUEST_LOGIN, packet.SessionID(), request.ID, jobDatas); DevLog.Write("DB에 로그인 요청 보냄", LOG_LEVEL.DEBUG); } catch(Exception ex) { DevLog.Write(ex.ToString(), LOG_LEVEL.DEBUG); } }
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 InnerNotifyEnterLobby(SFNETPacket packet) { var notify = JsonEnDecode.Decode <CSCommonLib.JsonPacketInnerNotifyEnterLobby>(packet.GetData()); var user = UserManagerRef.GetUser(notify.UserID); if (user == null) { var jsonData = new JsonPacketInnerRollBackEnterLobby() { LobbyID = notify.LobbyID, UserID = notify.UserID }; var bodyData = CGSFNETCommon.JsonEnDecode.Encode <JsonPacketInnerRollBackEnterLobby>(jsonData); var InnerPacket = new CgsfNET64Lib.SFNETPacket(); InnerPacket.SetData(-1, (ushort)PACKET_ID.INNER_ROLL_BACK_ENTER_LOBBY, bodyData); RelayPacketPacketProcess.RelayPacket(notify.LobbyID, InnerPacket); return; } if (notify.Result == ERROR_CODE.NONE) { user.SetLobby(notify.LobbyID); } else { user.SetLobby(0); } var response = new JsonPacketResponseEnterLobby() { Result = notify.Result, LobbyID = notify.LobbyID }; ServerNetworkRef.Send <JsonPacketResponseEnterLobby>(user.SessionID, PACKET_ID.RESPONSE_ENTER_LOBBY, response); }
public void InnerNotifyLeaveLobby(SFNETPacket packet) { var notify = JsonEnDecode.Decode<CSCommonLib.JsonPacketInnerNotifyLeaveLobby>(packet.GetData()); var user = UserManagerRef.GetUser(notify.UserID); if (user == null) { return; } user.SetLobby(0); var response = new JsonPacketResponseLeaveLobby() { Result = notify.Result }; ServerNetworkRef.Send<JsonPacketResponseLeaveLobby>(user.SessionID, PACKET_ID.RESPONSE_LEAVE_LOBBY, response); }