From 3762664c149a8a1d587d59ce203a9a61bde709b9 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 4 Mar 2018 00:38:51 +0800 Subject: [PATCH] Normalize line endings --- TLSharp.Core/Network/TcpTransport.cs | 24 +++---- TLSharp.Core/TelegramClient.cs | 96 ++++++++++++++-------------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/TLSharp.Core/Network/TcpTransport.cs b/TLSharp.Core/Network/TcpTransport.cs index 31bd6b4..e0f6e1f 100644 --- a/TLSharp.Core/Network/TcpTransport.cs +++ b/TLSharp.Core/Network/TcpTransport.cs @@ -84,21 +84,21 @@ namespace TLSharp.Core.Network } return new TcpMessage(seq, body); - } - - public bool IsConnected - { - get - { - return this._tcpClient.Connected; - } - } - - + } + + public bool IsConnected + { + get + { + return this._tcpClient.Connected; + } + } + + public void Dispose() { if (_tcpClient.Connected) _tcpClient.Close(); - } + } } } diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 45d15af..dd0593d 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -83,13 +83,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); - } + + 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); @@ -97,21 +97,21 @@ namespace TLSharp.Core _session.ServerAddress = dc.IpAddress; _session.Port = dc.Port; - 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)); + 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) - { + private async Task RequestWithDcMigration(TLMethod request) + { if (_sender == null) - throw new InvalidOperationException("Not connected!"); - + throw new InvalidOperationException("Not connected!"); + var completed = false; while(!completed) { @@ -127,7 +127,7 @@ namespace TLSharp.Core // prepare the request for another try request.ConfirmReceived = false; } - } + } } public bool IsUserAuthorized() @@ -170,8 +170,8 @@ namespace TLSharp.Core if (String.IsNullOrWhiteSpace(code)) throw new ArgumentNullException(nameof(code)); - var request = new TLRequestSignIn() { PhoneNumber = phoneNumber, PhoneCodeHash = phoneCodeHash, PhoneCode = code }; - + var request = new TLRequestSignIn() { PhoneNumber = phoneNumber, PhoneCodeHash = phoneCodeHash, PhoneCode = code }; + await RequestWithDcMigration(request); OnUserAuthenticated(((TLUser)request.Response.User)); @@ -312,21 +312,21 @@ namespace TLSharp.Core public async Task SendPingAsync() { await _sender.SendPingAsync(); - } - - public async Task GetHistoryAsync(TLAbsInputPeer peer, int offset, int max_id, int limit) - { - if (!IsUserAuthorized()) - throw new InvalidOperationException("Authorize user first!"); - - var req = new TLRequestGetHistory() - { - Peer = peer, - AddOffset = offset, - MaxId = max_id, - Limit = limit - }; - return await SendRequestAsync(req); + } + + public async Task GetHistoryAsync(TLAbsInputPeer peer, int offset, int max_id, int limit) + { + if (!IsUserAuthorized()) + throw new InvalidOperationException("Authorize user first!"); + + var req = new TLRequestGetHistory() + { + Peer = peer, + AddOffset = offset, + MaxId = max_id, + Limit = limit + }; + return await SendRequestAsync(req); } /// @@ -352,18 +352,18 @@ namespace TLSharp.Core _session.SessionExpires = int.MaxValue; _session.Save(); - } - - public bool IsConnected - { - get - { - if (_transport == null) - return false; - return _transport.IsConnected; - } - } - + } + + public bool IsConnected + { + get + { + if (_transport == null) + return false; + return _transport.IsConnected; + } + } + public void Dispose() { if (_transport != null)