diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 126370d..f1c8692 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -85,6 +85,13 @@ namespace TLSharp.Core { if (dcOptions == null || !dcOptions.Any()) throw new InvalidOperationException($"Can't reconnect. Establish initial connection first."); + + TLExportedAuthorization exported = null; + if (_session.TLUser != null) + { + TLRequestExportAuthorization exportAuthorization = new TLRequestExportAuthorization() { DcId = dcId }; + exported = await SendRequestAsync(exportAuthorization); + } var dc = dcOptions.First(d => d.Id == dcId); @@ -92,7 +99,14 @@ namespace TLSharp.Core _session.ServerAddress = dc.IpAddress; _session.Port = dc.Port; - await ConnectAsync(true); + await ConnectAsync(true); + + if (_session.TLUser != null) + { + TLRequestImportAuthorization importAuthorization = new TLRequestImportAuthorization() { Id = exported.Id, Bytes = exported.Bytes }; + var imported = await SendRequestAsync(importAuthorization); + OnUserAuthenticated(((TLUser)imported.User)); + } } private async Task RequestWithDcMigration(TLMethod request)