mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
testing first response
This commit is contained in:
parent
4d3a0832d5
commit
0f3611fb15
4 changed files with 9 additions and 4 deletions
|
@ -8,7 +8,7 @@ from arq_data_type_handler import ARQDataTypeHandler
|
|||
|
||||
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.logger = structlog.get_logger(type(self).__name__)
|
||||
self.state_manager = state_manager
|
||||
|
@ -16,6 +16,7 @@ class TxCommand():
|
|||
self.set_params_from_api(apiParams)
|
||||
self.frame_factory = DataFrameFactory(config)
|
||||
self.arq_data_type_handler = ARQDataTypeHandler(event_manager, state_manager)
|
||||
self.request = request
|
||||
|
||||
def log(self, message, isWarning = False):
|
||||
msg = f"[{type(self).__name__}]: {message}"
|
||||
|
|
|
@ -24,7 +24,7 @@ class P2PConnectionCommand(TxCommand):
|
|||
try:
|
||||
self.emit_event(event_queue)
|
||||
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:
|
||||
self.state_manager.register_p2p_connection_session(session)
|
||||
session.connect()
|
||||
|
|
|
@ -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.config = config
|
||||
self.frame_factory = data_frame_factory.DataFrameFactory(self.config)
|
||||
|
||||
self.request = request
|
||||
|
||||
self.destination = destination
|
||||
self.origin = origin
|
||||
self.states = state_manager
|
||||
|
@ -191,6 +193,8 @@ class P2PConnection:
|
|||
def session_failed(self):
|
||||
self.log("FAILED...........................")
|
||||
self.set_state(States.FAILED)
|
||||
message = "DISCONNECTED\r\n"
|
||||
self.request.sendall(message.encode())
|
||||
|
||||
def process_data_queue(self, frame=None):
|
||||
if not self.p2p_tx_queue.empty():
|
||||
|
|
|
@ -27,7 +27,7 @@ class SocketCommandHandler:
|
|||
'destination': "BB2BBB-2",
|
||||
'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)
|
||||
if session.session_id:
|
||||
self.state_manager.register_p2p_connection_session(session)
|
||||
|
|
Loading…
Reference in a new issue