From fc09dba71b9a84609ad46612a3dddf89696c8f0f Mon Sep 17 00:00:00 2001 From: salar2k Date: Thu, 15 Dec 2016 23:32:23 +0330 Subject: [PATCH] Implementing IDisposable --- TLSharp.Core/TelegramClient.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 8ce1d6a..ce6b522 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -21,7 +21,7 @@ using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization; namespace TLSharp.Core { - public class TelegramClient + public class TelegramClient : IDisposable { private MtProtoSender _sender; private AuthKey _key; @@ -333,6 +333,15 @@ namespace TLSharp.Core _session.Save(); } + + public void Dispose() + { + if (_transport != null) + { + _transport.Dispose(); + _transport = null; + } + } } public class MissingApiConfigurationException : Exception