FreeDATA/freedata_server/socket_interface_commands.py

77 lines
2.4 KiB
Python
Raw Normal View History

2024-03-25 18:29:30 +00:00
""" WORK IN PROGRESS by DJ2LS"""
from command_p2p_connection import P2PConnectionCommand
class SocketCommandHandler:
2024-03-16 14:52:14 +00:00
def __init__(self, cmd_request, modem, config_manager, state_manager, event_manager):
self.cmd_request = cmd_request
2024-03-16 12:44:58 +00:00
self.modem = modem
self.config_manager = config_manager
self.state_manager = state_manager
2024-03-16 12:44:58 +00:00
self.event_manager = event_manager
2024-03-19 10:19:13 +00:00
self.session = None
def send_response(self, message):
2024-03-16 14:52:14 +00:00
full_message = f"{message}\r\n"
self.cmd_request.sendall(full_message.encode())
def handle_connect(self, data):
2024-03-16 12:44:58 +00:00
params = {
2024-03-16 14:52:14 +00:00
'origin': data[0],
'destination': data[1],
}
2024-03-16 14:52:14 +00:00
cmd = P2PConnectionCommand(self.config_manager.read(), self.state_manager, self.event_manager, params, self)
2024-03-19 10:19:13 +00:00
self.session = cmd.run(self.event_manager.queues, self.modem)
2024-03-27 18:55:19 +00:00
#if self.session.session_id:
# self.state_manager.register_p2p_connection_session(self.session)
# self.send_response("OK")
# self.session.connect()
#else:
# self.send_response("ERROR")
def handle_disconnect(self, data):
2024-03-16 14:52:14 +00:00
# Your existing connect logic
self.send_response("OK")
def handle_mycall(self, data):
# Logic for handling MYCALL command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def handle_bw(self, data):
# Logic for handling BW command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def handle_abort(self, data):
# Logic for handling ABORT command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def handle_public(self, data):
# Logic for handling PUBLIC command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def handle_cwid(self, data):
# Logic for handling CWID command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def handle_listen(self, data):
# Logic for handling LISTEN command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def handle_compression(self, data):
# Logic for handling COMPRESSION command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def handle_winlink_session(self, data):
# Logic for handling WINLINK SESSION command
2024-03-16 14:52:14 +00:00
self.send_response("OK")
def socket_respond_disconnected(self):
self.send_response("DISCONNECTED")
2024-03-16 15:11:38 +00:00
def socket_respond_connected(self, mycall, dxcall, bandwidth):
message = f"CONNECTED {mycall} {dxcall} {bandwidth}"
self.send_response(message)