示例#1
0
        public async Task SaveAuthorization(auth_Authorization authorization)
        {
            this.authorization = (Auth_authorizationConstructor)authorization;
            SaveUser(this.authorization.user);
            Task dialogsTask = dialogs.DialogsRequest();
            Task updateTask  = updates.GetStateRequest();
            await Task.WhenAll(dialogsTask, updateTask);

            save();
        }
示例#2
0
        public async Task <TLApi> GetFileSession(int dc)
        {
            logger.debug("Getting file session for dc {0}", dc);
            await             Established;
            ConfigConstructor config = (ConfigConstructor)gateway.Config;

            TelegramDC targetDc;

            if (dcs.ContainsKey(dc))
            {
                targetDc = dcs[dc];
            }
            else
            {
                targetDc = new TelegramDC();
                foreach (var dcOption in config.dc_options)
                {
                    DcOptionConstructor optionConstructor = (DcOptionConstructor)dcOption;
                    if (optionConstructor.id == dc)
                    {
                        TelegramEndpoint endpoint = new TelegramEndpoint(optionConstructor.ip_address, optionConstructor.port);
                        targetDc.Endpoints.Add(endpoint);
                    }
                }

                dcs[dc] = targetDc;
            }

            MTProtoGateway fileGateway = await targetDc.GetFileGateway(gateway.Salt);

            TLApi fileGatewayApi = new TLApi(fileGateway);

            if (targetDc.FileAuthorized || dc == mainDcId)
            {
                return(fileGatewayApi);
            }

            Task <auth_ExportedAuthorization>     exportAuthTask = Api.auth_exportAuthorization(dc);
            Auth_exportedAuthorizationConstructor exportedAuth   = (Auth_exportedAuthorizationConstructor)await exportAuthTask;
            auth_Authorization authorization = await fileGatewayApi.auth_importAuthorization(exportedAuth.id, exportedAuth.bytes);

            targetDc.SaveFileAuthorization(authorization);

            return(fileGatewayApi);
        }
示例#3
0
 public async Task SaveAuthorization(auth_Authorization authorization) {
     this.authorization = (Auth_authorizationConstructor) authorization;
     SaveUser(this.authorization.user);
     Task dialogsTask = dialogs.DialogsRequest();
     Task updateTask = updates.GetStateRequest();
     await Task.WhenAll(dialogsTask, updateTask);
     save();
 }
示例#4
0
 public void SaveFileAuthorization(auth_Authorization authorization) {
     this.fileAuthorization = (Auth_authorizationConstructor) authorization;
 }
示例#5
0
 public void SaveFileAuthorization(auth_Authorization authorization)
 {
     this.fileAuthorization = (Auth_authorizationConstructor)authorization;
 }