testing first response

This commit is contained in:
DJ2LS 2024-03-16 13:57:48 +01:00
parent 4d3a0832d5
commit 0f3611fb15
4 changed files with 9 additions and 4 deletions

View file

@ -8,7 +8,7 @@ from arq_data_type_handler import ARQDataTypeHandler
class TxCommand(): class TxCommand():
def __init__(self, config: dict, state_manager: StateManager, event_manager, apiParams:dict = {}): def __init__(self, config: dict, state_manager: StateManager, event_manager, apiParams:dict = {}, request=None):
self.config = config self.config = config
self.logger = structlog.get_logger(type(self).__name__) self.logger = structlog.get_logger(type(self).__name__)
self.state_manager = state_manager self.state_manager = state_manager
@ -16,6 +16,7 @@ class TxCommand():
self.set_params_from_api(apiParams) self.set_params_from_api(apiParams)
self.frame_factory = DataFrameFactory(config) self.frame_factory = DataFrameFactory(config)
self.arq_data_type_handler = ARQDataTypeHandler(event_manager, state_manager) self.arq_data_type_handler = ARQDataTypeHandler(event_manager, state_manager)
self.request = request
def log(self, message, isWarning = False): def log(self, message, isWarning = False):
msg = f"[{type(self).__name__}]: {message}" msg = f"[{type(self).__name__}]: {message}"

View file

@ -24,7 +24,7 @@ class P2PConnectionCommand(TxCommand):
try: try:
self.emit_event(event_queue) self.emit_event(event_queue)
self.logger.info(self.log_message()) self.logger.info(self.log_message())
session = P2PConnection(self.config, modem, self.origin, self.destination, self.state_manager) session = P2PConnection(self.config, modem, self.origin, self.destination, self.state_manager, self.request)
if session.session_id: if session.session_id:
self.state_manager.register_p2p_connection_session(session) self.state_manager.register_p2p_connection_session(session)
session.connect() session.connect()

View file

@ -49,11 +49,13 @@ class P2PConnection:
}, },
} }
def __init__(self, config: dict, modem, origin: str, destination: str, state_manager): def __init__(self, config: dict, modem, origin: str, destination: str, state_manager, request=None):
self.logger = structlog.get_logger(type(self).__name__) self.logger = structlog.get_logger(type(self).__name__)
self.config = config self.config = config
self.frame_factory = data_frame_factory.DataFrameFactory(self.config) self.frame_factory = data_frame_factory.DataFrameFactory(self.config)
self.request = request
self.destination = destination self.destination = destination
self.origin = origin self.origin = origin
self.states = state_manager self.states = state_manager
@ -191,6 +193,8 @@ class P2PConnection:
def session_failed(self): def session_failed(self):
self.log("FAILED...........................") self.log("FAILED...........................")
self.set_state(States.FAILED) self.set_state(States.FAILED)
message = "DISCONNECTED\r\n"
self.request.sendall(message.encode())
def process_data_queue(self, frame=None): def process_data_queue(self, frame=None):
if not self.p2p_tx_queue.empty(): if not self.p2p_tx_queue.empty():

View file

@ -27,7 +27,7 @@ class SocketCommandHandler:
'destination': "BB2BBB-2", 'destination': "BB2BBB-2",
'origin': "AA1AAA-1", 'origin': "AA1AAA-1",
} }
cmd = P2PConnectionCommand(self.config_manager.read(), self.state_manager, self.event_manager, params) cmd = P2PConnectionCommand(self.config_manager.read(), self.state_manager, self.event_manager, params, self.request)
session = cmd.run(self.event_manager.queues, self.modem) session = cmd.run(self.event_manager.queues, self.modem)
if session.session_id: if session.session_id:
self.state_manager.register_p2p_connection_session(session) self.state_manager.register_p2p_connection_session(session)