Exemplo n.º 1
0
        public async Task <T> Call <T>(ITgFunc <T> func)
        {
            TgCallHandler <T> handler = f => Transport.Call(f);

            handler = CallMiddlewareChain.Apply(handler);

            // TODO: refactor it
            const int attemptsCount  = 10;
            var       currentAttempt = 1;

            while (true)
            {
                try
                {
                    var respTask = await handler(func);

                    return(await respTask);
                }
                catch (TgBadSaltException) when(currentAttempt < attemptsCount)
                {
                }
                catch (TgRpcBadMsgException e) when(currentAttempt < attemptsCount && e.ErrorCode == TgRpcBadMsgCodes.MsgSeqNoLow)
                {
                }

                currentAttempt++;
            }
        }
Exemplo n.º 2
0
 static bool IsIgnored <T>(ITgFunc <T> func) =>
 func is GetFile ||
 func is GetCdnFile ||
 func is GetWebFile ||
 func is SaveFilePart ||
 func is SaveBigFilePart ||
 func is GetFileHashes ||
 func is ReuploadCdnFile ||
 func is GetCdnFileHashes;
Exemplo n.º 3
0
        async Task <T> CallWithMigration <T>(ITgFunc <T> func)
        {
            try
            {
                return(await CallWithReConnect(func));
            }
            catch (TgDataCenterMigrationException e)
            {
                await ChangeConn(x => ConnectionPool.Connect(x, e.Dc));

                return(await CallWithReConnect(func));
            }
        }
Exemplo n.º 4
0
        async Task <T> CallWithReConnect <T>(ITgFunc <T> func)
        {
            try
            {
                var conn = CurrentConnection.Get();
                return(await conn.Transport.Call(func));
            }
            catch (TgBrokenConnectionException)
            {
                var conn = await ChangeConn(x => ConnectionPool.ReConnect(x.Config.ThisDc));

                return(await conn.Transport.Call(func));
            }
        }
Exemplo n.º 5
0
 public Task <T> Call <T>(ITgFunc <T> func) =>
 TaskWrapper.Wrap(() => CallWithMigration(func));
Exemplo n.º 6
0
 public Task <T> Call <T>(ITgFunc <T> func) =>
 _bellhop.Call(func);