idz: add socket servers

This commit is contained in:
2024-01-09 12:21:31 -05:00
parent 4b9db8be3b
commit f65aa4d60a
4 changed files with 77 additions and 114 deletions

View File

@ -4,16 +4,11 @@ import logging
from core.config import CoreConfig
from .config import IDZConfig
class IDZEcho:
def connection_made(self, transport):
self.transport = transport
class IDZEcho(DatagramProtocol):
def __init__(self, cfg: CoreConfig, game_cfg: IDZConfig) -> None:
super().__init__()
self.core_config = cfg
self.game_config = game_cfg
self.logger = logging.getLogger("idz")
def datagramReceived(self, data, addr):
self.logger.debug(
f"Echo from from {addr[0]}:{addr[1]} -> {self.transport.getHost().port} - {data.hex()}"
)
self.transport.write(data, addr)
def datagram_received(self, data, addr):
message = data.decode()
self.logger.debug(f'Received echo from {addr}')
self.transport.sendto(data, addr)