Exemple #1
0
        private async Task ReconnectImpl()
        {
            await CloseProto();

            Debug.WriteLine("Creating new transport..");
            if (session.authKey == null)
            {
                var result = await Authenticator.Authenticate(session.serverAddress, session.port);

                session.authKey    = result.authKey;
                session.timeOffset = result.timeOffset;
                session.salt       = result.serverSalt;
            }

            protoSender = new MtProtoSender(session);

            Subscribe();
            protoSender.Start();

            var request = new InitConnectionAndGetConfigRequest(apiLayer, apiId, deviceInfo);

            await SendRpcRequest(request);

            configuration = request.config;
            dcOptions     = new DcOptionsCollection(request.config.dcOptions);

            OnConnectionStateChanged(ConnectionStateEventArgs.Connected());
        }
        private async Task ReconnectImpl()
        {
            await CloseProto();

            Debug.WriteLine("Creating new transport..");
            if (ClientSettings.Session.AuthKey == null)
            {
                Step3_Response result = await Authenticator.Authenticate(ClientSettings.Session.ServerAddress, ClientSettings.Session.Port);

                ClientSettings.Session.AuthKey    = result.authKey;
                ClientSettings.Session.TimeOffset = result.timeOffset;
                ClientSettings.Session.Salt       = result.serverSalt;
            }

            _protoSender = new MtProtoSender(ClientSettings.Session);

            Subscribe();
            _protoSender.Start();

            var request = new InitConnectionAndGetConfigRequest(s_apiLayer, ClientSettings.AppId, _deviceInfo);

            await SendRpcRequest(request);

            _configuration = request.config;
            _dcOptions     = new DcOptionsCollection(request.config.dcOptions);

            OnConnectionStateChanged(ConnectionStateEventArgs.Connected());
        }