MtProtoPlainSender was not connecting (closes #62)

This commit is contained in:
Lonami Exo 2017-04-29 20:57:08 +02:00
parent fbe65c2dfb
commit 6069188b54
2 changed files with 7 additions and 4 deletions

View File

@ -12,6 +12,7 @@ class MtProtoPlainSender:
self._time_offset = 0
self._last_msg_id = 0
self._transport = transport
self._transport.connect()
def send(self, data):
"""Sends a plain packet (auth_key_id = 0) containing the given message body (data)"""

View File

@ -31,13 +31,15 @@ class TcpClient:
def connect(self, ip, port):
"""Connects to the specified IP and port number"""
self.socket.connect((ip, port))
self.connected = True
if not self.connected:
self.socket.connect((ip, port))
self.connected = True
def close(self):
"""Closes the connection"""
self.socket.close()
self.connected = False
if self.connected:
self.socket.close()
self.connected = False
def write(self, data):
"""Writes (sends) the specified bytes to the connected peer"""