Added heartbeat return on peer.py test
This commit is contained in:
@@ -177,6 +177,7 @@ class ConnectorEndpoint:
|
|||||||
first_received = True
|
first_received = True
|
||||||
if received.return_timestamp is not None:
|
if received.return_timestamp is not None:
|
||||||
last_recieved = received.return_timestamp
|
last_recieved = received.return_timestamp
|
||||||
|
log.debug("Received heartbeat")
|
||||||
|
|
||||||
if not first_received:
|
if not first_received:
|
||||||
if ctr > round(
|
if ctr > round(
|
||||||
|
|||||||
+5
-1
@@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
from time import monotonic
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from dynalab_core.protocols.packets import ProtocolMessage
|
from dynalab_core.protocols.packets import ProtocolMessage
|
||||||
@@ -9,6 +10,7 @@ from dynalab_core.protocols.common import VersionDescriptor
|
|||||||
from dynalab_core.protocols.constants import PROTOCOL_VERSION
|
from dynalab_core.protocols.constants import PROTOCOL_VERSION
|
||||||
from dynalab_core.protocols.json.wire import read_message, write_message
|
from dynalab_core.protocols.json.wire import read_message, write_message
|
||||||
from dynalab_core.protocols.packets.handshake import ConnectorHello, DynaLabHello
|
from dynalab_core.protocols.packets.handshake import ConnectorHello, DynaLabHello
|
||||||
|
from dynalab_core.protocols.packets.heartbeat import Heartbeat
|
||||||
|
|
||||||
CONNECTOR_VERSION = VersionDescriptor(type="alpha", major=0, minor=0, patch=1)
|
CONNECTOR_VERSION = VersionDescriptor(type="alpha", major=0, minor=0, patch=1)
|
||||||
|
|
||||||
@@ -57,7 +59,9 @@ async def main() -> None:
|
|||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
message = await read_message(reader)
|
message = await read_message(reader)
|
||||||
log.info(message)
|
if isinstance(message, Heartbeat):
|
||||||
|
message.return_timestamp = round(monotonic() * 1000)
|
||||||
|
await write_message(writer, message)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user