Don't do anything on .connect() if it's already connected

This commit is contained in:
Lonami Exo
2017-06-20 09:46:37 +02:00
parent daa626aa04
commit 697434be37
3 changed files with 12 additions and 0 deletions
+3
View File
@@ -35,6 +35,9 @@ class MtProtoSender:
"""Connects to the server"""
self._transport.connect()
def is_connected(self):
return self._transport.is_connected()
def disconnect(self):
"""Disconnects from the server"""
self._transport.close()
+3
View File
@@ -18,6 +18,9 @@ class TcpTransport:
self.send_counter = 0
self.tcp_client.connect(self.ip, self.port)
def is_connected(self):
return self.tcp_client.connected
# Original reference: https://core.telegram.org/mtproto#tcp-transport
# The packets are encoded as: total length, sequence number, packet and checksum (CRC32)
def send(self, packet):