diff --git a/src/control_backend/agents/ri_communication_agent.py b/src/control_backend/agents/ri_communication_agent.py index f46c623..79e44ed 100644 --- a/src/control_backend/agents/ri_communication_agent.py +++ b/src/control_backend/agents/ri_communication_agent.py @@ -86,6 +86,9 @@ class RICommunicationAgent(Agent): # See what endpoint we received match message["endpoint"]: case "ping": + topic = b"ping" + data = json.dumps(True).encode() + await self.agent._pub_socket.send_multipart([topic, data]) await asyncio.sleep(1) case _: logger.info( diff --git a/src/control_backend/api/v1/endpoints/robot.py b/src/control_backend/api/v1/endpoints/robot.py index aa1b532..b8291ac 100644 --- a/src/control_backend/api/v1/endpoints/robot.py +++ b/src/control_backend/api/v1/endpoints/robot.py @@ -45,7 +45,7 @@ async def ping_stream(request: Request): sub_socket = context.socket(zmq.SUB) sub_socket.connect(settings.zmq_settings.internal_comm_address) sub_socket.setsockopt(zmq.SUBSCRIBE, b"ping") - connected = True + connected = False ping_frequency = 1 # How many seconds between ping attempts @@ -68,7 +68,8 @@ async def ping_stream(request: Request): logger.debug(f"Yielded new connection event in robot ping router: {str(connected)}") - yield f"data: {str(connected)}, time:{str(datetime.datetime.now().strftime("%H:%M:%S"))}\n\n" + falseJson = json.dumps(connected) + yield (f"data: {falseJson}\n\n") return StreamingResponse(event_stream(), media_type="text/event-stream") \ No newline at end of file