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 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 SystemClientDisConnected(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } if (user.LobbyID > 0) { var jsonData = new JsonPacketRequestLeaveLobby() { LobbyID = user.LobbyID, UserID = user.UserID }; var bodyData = JsonEnDecode.Encode <JsonPacketRequestLeaveLobby>(jsonData); var InnerPacket = new CgsfNET64Lib.SFNETPacket(); InnerPacket.SetData(-1, (ushort)PACKET_ID.REQUEST_LEAVE_LOBBY, bodyData); RelayPacketPacketProcess.RelayPacket(user.LobbyID, InnerPacket); } var result = UserManagerRef.RemoveUser(packet.SessionID()); InnerMessageQueue.CurrentUserCount(UserManagerRef.GetConnectCount()); DevLog.Write(string.Format("Client DisConnected. SessionID: {0}", packet.SessionID()), LOG_LEVEL.INFO); }
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 SystemClientConnect(SFNETPacket packet) { var result = UserManagerRef.AddUser(packet.SessionID()); InnerMessageQueue.CurrentUserCount(UserManagerRef.GetConnectCount()); if (result == CSCommonLib.ERROR_CODE.NONE) { DevLog.Write(string.Format("Client Connect. SessionID: {0}", packet.SessionID()), LOG_LEVEL.INFO); } else { DevLog.Write(string.Format("Client Connect. SessionID: {0}, Error:{1}", packet.SessionID(), result.ToString()), LOG_LEVEL.ERROR); } }
public void Process(SFNETPacket packet) { var packetID = packet.PacketID(); if (packetID > (ushort)PACKET_ID.CLIENT_RANGE_FIRST && packetID < (ushort)PACKET_ID.CLIENT_RANGE_LAST) { if (ClientPacketHandlerMap.ContainsKey(packetID)) { var user = UserManager.GetUser(packet.SessionID()); ClientPacketHandlerMap[packetID](packet, user); return; } } if (packetID > (ushort)PACKET_ID.SERVER_RANGE_FIRST && packetID < (ushort)PACKET_ID.SERVER_RANGE_LAST) { if (ServerPacketHandlerMap.ContainsKey(packetID)) { ServerPacketHandlerMap[packetID](packet); return; } } DevLog.Write(string.Format("[PacketProcess] Invalid PacketID:{0}", packetID), LOG_LEVEL.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 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 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 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 Process(SFNETPacket packet) { var packetID = packet.PacketID(); if (PacketHandlerMap.ContainsKey(packetID)) { var user = UserManager.GetUser(packet.SessionID()); PacketHandlerMap[packetID](packet, user); } else { DevLog.Write(string.Format("[PacketProcess] Invalid PacketID:{0}", packetID), LOG_LEVEL.ERROR); } }
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 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 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 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 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 SystemClientDisConnected(SFNETPacket packet) { var user = UserManagerRef.GetUser(packet.SessionID()); if (user == null) { return; } if (user.LobbyID > 0) { var jsonData = new JsonPacketRequestLeaveLobby() { LobbyID = user.LobbyID, UserID = user.UserID }; var bodyData = JsonEnDecode.Encode<JsonPacketRequestLeaveLobby>(jsonData); var InnerPacket = new CgsfNET64Lib.SFNETPacket(); InnerPacket.SetData(-1, (ushort)PACKET_ID.REQUEST_LEAVE_LOBBY, bodyData); RelayPacketPacketProcess.RelayPacket(user.LobbyID, InnerPacket); } var result = UserManagerRef.RemoveUser(packet.SessionID()); InnerMessageQueue.CurrentUserCount(UserManagerRef.GetConnectCount()); DevLog.Write(string.Format("Client DisConnected. SessionID: {0}", packet.SessionID()), LOG_LEVEL.INFO); }
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); } }
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); } } }