From c5187ae12b72d59667d4f09c9a8be7cc56a80dea Mon Sep 17 00:00:00 2001 From: salarcode Date: Mon, 24 Apr 2017 19:16:53 +0430 Subject: [PATCH] Implementing IsConnected Closes #460 --- TLSharp.Core/Network/TcpTransport.cs | 13 +++++++++++-- TLSharp.Core/TelegramClient.cs | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/TLSharp.Core/Network/TcpTransport.cs b/TLSharp.Core/Network/TcpTransport.cs index 254153e..31bd6b4 100644 --- a/TLSharp.Core/Network/TcpTransport.cs +++ b/TLSharp.Core/Network/TcpTransport.cs @@ -84,8 +84,17 @@ namespace TLSharp.Core.Network } return new TcpMessage(seq, body); - } - + } + + public bool IsConnected + { + get + { + return this._tcpClient.Connected; + } + } + + public void Dispose() { if (_tcpClient.Connected) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index a4fa06a..825f9a7 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -377,8 +377,18 @@ namespace TLSharp.Core _session.SessionExpires = int.MaxValue; _session.Save(); - } - + } + + public bool IsConnected + { + get + { + if (_transport == null) + return false; + return _transport.IsConnected; + } + } + public void Dispose() { if (_transport != null)