TimeSpan as param

This commit is contained in:
Arthur Grand 2019-09-12 16:09:55 +07:00 committed by GitHub
parent 64440e4736
commit 1a7ffd4678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,7 +31,7 @@ namespace TLSharp.Core
private TimeSpan _requestTimeout; private TimeSpan _requestTimeout;
public TelegramClient(int apiId, string apiHash, public TelegramClient(int apiId, string apiHash,
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null, double requestTimeout = 5d) ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null, TimeSpan? requestTimeout = null)
{ {
if (apiId == default(int)) if (apiId == default(int))
throw new MissingApiConfigurationException("API_ID"); throw new MissingApiConfigurationException("API_ID");
@ -44,7 +44,7 @@ namespace TLSharp.Core
_apiHash = apiHash; _apiHash = apiHash;
_apiId = apiId; _apiId = apiId;
_handler = handler; _handler = handler;
_requestTimeout = TimeSpan.FromSeconds(requestTimeout); _requestTimeout = requestTimeout ?? TimeSpan.FromSeconds(5);
_session = Session.TryLoadOrCreateNew(store, sessionUserId); _session = Session.TryLoadOrCreateNew(store, sessionUserId);
_transport = new TcpTransport(_session.DataCenter.Address, _session.DataCenter.Port, _handler); _transport = new TcpTransport(_session.DataCenter.Address, _session.DataCenter.Port, _handler);