From cba347dc896390ca32b711ed64ea1eb39c452aa4 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Thu, 13 Jan 2022 14:22:52 +0100 Subject: [PATCH] clone TcpHandler & PingInterval for secondary DCs --- src/Client.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Client.cs b/src/Client.cs index 731371c..8acc628 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -28,7 +28,9 @@ namespace WTelegram public event Action Update; public delegate Task TcpFactory(string host, int port); /// Used to create a TcpClient connected to the given address/port, or throw an exception on failure - public TcpFactory TcpHandler = DefaultTcpHandler; + public TcpFactory TcpHandler { get; set; } = DefaultTcpHandler; + /// Url for using a MTProxy. https://t.me/proxy?server=... + public string MTProxyUrl { get; set; } /// Telegram configuration, obtained at connection time public Config TLConfig { get; private set; } /// Number of automatic reconnections on connection/reactor failure @@ -41,8 +43,6 @@ namespace WTelegram public bool IsMainDC => (_dcSession?.DataCenter?.id ?? 0) == _session.MainDC; /// Has this Client established connection been disconnected? public bool Disconnected => _tcpClient != null && !(_tcpClient.Client?.Connected ?? false); - /// Url for using a MTProxy. http://t.me/proxy?server=... - public string MTProxyUrl { get; set; } /// Used to indicate progression of file download/upload /// total size of file in bytes, or 0 if unknown @@ -100,11 +100,13 @@ namespace WTelegram private Client(Client cloneOf, Session.DCSession dcSession) { - MTProxyUrl = cloneOf.MTProxyUrl; _config = cloneOf._config; _apiId = cloneOf._apiId; _apiHash = cloneOf._apiHash; _session = cloneOf._session; + TcpHandler = cloneOf.TcpHandler; + MTProxyUrl = cloneOf.MTProxyUrl; + PingInterval = cloneOf.PingInterval; _dcSession = dcSession; }