feat: started ping router and internal messaging for pings
ref: N25B-151
This commit is contained in:
@@ -5,11 +5,13 @@ from spade.agent import Agent
|
||||
from spade.behaviour import CyclicBehaviour
|
||||
import zmq
|
||||
|
||||
|
||||
from control_backend.core.config import settings
|
||||
from control_backend.core.zmq_context import context
|
||||
from control_backend.schemas.message import Message
|
||||
from control_backend.schemas.ri_message import RIMessage
|
||||
from control_backend.agents.ri_command_agent import RICommandAgent
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -63,6 +65,11 @@ class RICommunicationAgent(Agent):
|
||||
logger.info(f"No ping back retrieved in {seconds_to_wait_total/2} seconds totalling {seconds_to_wait_total} of time, killing myself.")
|
||||
self.agent.connected = False
|
||||
# TODO: Send event to UI letting know that we've lost connection
|
||||
topic = b"ping"
|
||||
data = json.dumps(False).encode()
|
||||
pub_socket = context.socket(zmq.PUB)
|
||||
pub_socket.connect(settings.zmq_settings.internal_comm_address)
|
||||
pub_socket.send_multipart([topic, data])
|
||||
|
||||
self.kill()
|
||||
|
||||
@@ -90,6 +97,7 @@ class RICommunicationAgent(Agent):
|
||||
logger.info("Setting up %s", self.jid)
|
||||
retries = 0
|
||||
|
||||
|
||||
# Let's try a certain amount of times before failing connection
|
||||
while retries < max_retries:
|
||||
# Bind request socket
|
||||
|
||||
Reference in New Issue
Block a user