Пример #1
0
        public override void Dispose()
        {
            _socket?.Dispose();
            _loginClient?.Dispose();

            base.Dispose();
        }
Пример #2
0
    public void OnDestroy()
    {
        Debug.Log("OnDestroy");
        _logger.InfoFormat("Start Destroy...");
        _isDestroy = true;
        MyHttpServer.Stop();
        if (_loginClient != null)
        {
            _loginClient.Dispose();
        }

        _logger.InfoFormat("Login Client Disposed.");
        HallUtility.ClearAciton();

        _clientRoom.Dispose();
        DefaultGo.Clear(GameRunningStage.BattleClient);
        SingletonManager.Dispose();

#if UNITY_SOURCE_MODIFIED && !UNITY_EDITOR
        UnityProfiler.DisableProfiler();
#endif
        _logger.InfoFormat("Client Destroy Completed.");
    }
Пример #3
0
        /// <summary>
        /// Login to the login server.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Login(string username, string password)
        {
            if (lc != null)
                lc.Dispose();

            lc = new LoginClient(5, protocolVersion);

            lc.LoginDisconnected += new LoginClientEvent(HandleDisconnectEvent);
            lc.LoginConnected += new LoginClientEvent(HandleConnectEvent);

            if (lc.Connect(host, port))
            {
                State = LoginConnectionState.ConnectedToLogin;

                if (lc.Login(username, password))
                {
                    State = LoginConnectionState.WorldListReceived;
                    worldList = lc.WorldServers;
                    accountId = lc.AccountId;
                }
                else
                {
                    disconnectMessage = "Unable to login.";
                    State = LoginConnectionState.Disconnected;

                    lc.Dispose();
                }
            }
            else
            {
                disconnectMessage = "Unabe to connect.";
                State = LoginConnectionState.Disconnected;

                lc.Dispose();
            }

            return (state == LoginConnectionState.WorldListReceived);
        }