Initialize() публичный Метод

public Initialize ( EncryptionBase encryptor, Type packetHandler, bool isWorldServer ) : void
encryptor OpenNos.Core.EncryptionBase
packetHandler System.Type
isWorldServer bool
Результат void
Пример #1
0
        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;
                }
                ;
            }
        }
Пример #2
0
        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;
            }
            ;
        }
Пример #3
0
        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);
        }