This commit is contained in:
Andres G. Aragoneses 2022-02-13 10:31:06 +03:00 committed by GitHub
commit 0615663eec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,8 @@ namespace TLSharp.Core
private string apiHash = String.Empty;
private int apiId = 0;
private Session session;
private string sessionUserId;
private ISessionStore store;
private List<TLDcOption> dcOptions;
private TcpClientConnectionHandler handler;
private DataCenterIPVersion dcIpVersion;
@ -58,20 +60,22 @@ namespace TLSharp.Core
if (store == null)
store = new FileSessionStore();
this.store = store;
this.apiHash = apiHash;
this.apiId = apiId;
this.handler = handler;
this.dcIpVersion = dcIpVersion;
session = Session.TryLoadOrCreateNew(store, sessionUserId);
transport = new TcpTransport (session.DataCenter.Address, session.DataCenter.Port, this.handler);
this.sessionUserId = sessionUserId;
}
public async Task ConnectAsync(bool reconnect = false, CancellationToken token = default(CancellationToken))
{
token.ThrowIfCancellationRequested();
session = Session.TryLoadOrCreateNew (store, sessionUserId);
transport = new TcpTransport (session.DataCenter.Address, session.DataCenter.Port, this.handler);
if (session.AuthKey == null || reconnect)
{
var result = await Authenticator.DoAuthentication(transport, token).ConfigureAwait(false);