@@ -41,8 +41,6 @@ def __init__(self, controller):
41
41
self ._out_pending = 0
42
42
self ._out_queue = SimpleQueue ()
43
43
44
- # the coroutine for sending regular 'ping' to IntelliCenter
45
- self ._heartbeat = None
46
44
# and the number of unacknowledgged ping issued
47
45
self ._num_unacked_pings = 0
48
46
@@ -52,19 +50,12 @@ def connection_made(self, transport):
52
50
self ._transport = transport
53
51
self ._msgID = 1
54
52
55
- # start a task to send 'ping' every 30s
56
- self ._heartbeat = asyncio .create_task (self .heartbeat ())
57
-
58
53
# and notify our controller that we are ready!
59
54
self ._controller .connection_made (self , transport )
60
55
61
56
def connection_lost (self , exc ):
62
57
"""Handle the callback for connection lost."""
63
58
64
- if self ._heartbeat :
65
- self ._heartbeat .cancel ()
66
- self ._heartbeat = None
67
-
68
59
self ._controller .connection_lost (exc )
69
60
70
61
def data_received (self , data ) -> None :
@@ -181,18 +172,3 @@ def processMessage(self, message: str) -> None:
181
172
182
173
except Exception as err :
183
174
_LOGGER .error (f"PROTOCOL: exception while receiving message { err } " )
184
-
185
- async def heartbeat (self ):
186
- """Send a ping every 10s to keep and check that the connection is alive."""
187
-
188
- while self ._num_unacked_pings < 2 :
189
- # we sleep first as there is no need for an immediate ping upon connection
190
- await asyncio .sleep (10 )
191
- _LOGGER .debug ("PROTOCOL: sending ping" )
192
- self .sendRequest ("ping" )
193
- self ._num_unacked_pings += 1
194
-
195
- # if we already have sent 2 pings without a pong
196
- # we assume the connection went dead and abort
197
- _LOGGER .error ("PROTOCOL: heartbeat missed, closing connection" )
198
- self ._transport .close ()
0 commit comments