Added heartbeat return on peer.py test
This commit is contained in:
+5
-1
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from time import monotonic
|
||||
from uuid import uuid4
|
||||
|
||||
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.json.wire import read_message, write_message
|
||||
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)
|
||||
|
||||
@@ -57,7 +59,9 @@ async def main() -> None:
|
||||
try:
|
||||
while True:
|
||||
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:
|
||||
return
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user