private void Server_ClientConnected(object sender, ServerClientEventArgs e) { Logger.Log.Info(Language.Instance.GetMessageFromKey("NEW_CONNECT") + e.Client.ClientId); NetworkClient customClient = e.Client as NetworkClient; if (!CheckGeneralLog(customClient)) { Logger.Log.WarnFormat(Language.Instance.GetMessageFromKey("FORCED_DISCONNECT"), customClient.ClientId); customClient.Initialize(_fallbackEncryptor); customClient.SendPacket($"fail {Language.Instance.GetMessageFromKey("CONNECTION_LOST")}"); customClient.Disconnect(); customClient = null; return; } ClientSession session = new ClientSession(customClient); session.Initialize(_encryptor, _packetHandler); if (IsWorldServer) { ServerManager.Instance.RegisterSession(session); if (!_sessions.TryAdd(customClient.ClientId, session)) { Logger.Log.WarnFormat(Language.Instance.GetMessageFromKey("FORCED_DISCONNECT"), customClient.ClientId); customClient.Disconnect(); _sessions.TryRemove(customClient.ClientId, out session); ServerManager.Instance.UnregisterSession(session); return; } ; } }
void Server_ClientConnected(object sender, ServerClientEventArgs e) { Logger.Log.Info(Language.Instance.GetMessageFromKey("NEW_CONNECT") + e.Client.ClientId); NetworkClient customClient = e.Client as NetworkClient; if (!CheckConnectionLog(customClient)) { Logger.Log.WarnFormat(Language.Instance.GetMessageFromKey("FORCED_DISCONNECT"), customClient.ClientId); customClient.Disconnect(); return; } ClientSession session = new ClientSession(customClient); session.Initialize(_encryptor, _packetHandler); ClientLinkManager.Instance.sessions.Add(session); if (!_sessions.TryAdd(customClient.ClientId, session)) { ClientLinkManager.Instance.sessions.Remove(session); Logger.Log.WarnFormat(Language.Instance.GetMessageFromKey("FORCED_DISCONNECT"), customClient.ClientId); customClient.Disconnect(); _sessions.TryRemove(customClient.ClientId, out session); return; } ; }
protected override ClientSession IntializeNewSession(INetworkClient client) { if (!CheckGeneralLog(client)) { Logger.Log.WarnFormat(Language.Instance.GetMessageFromKey("FORCED_DISCONNECT"), client.ClientId); client.Initialize(_fallbackEncryptor); client.SendPacket($"fail {Language.Instance.GetMessageFromKey("CONNECTION_LOST")}"); client.Disconnect(); return(null); } ClientSession session = new ClientSession(client); session.Initialize(_encryptor, _packetHandler, IsWorldServer); return(session); }