from .core.network import UdpHandler
from .core.dispatcher import MessageDispatcher

def on_packet_received(data, addr):
    header, msg = dispatcher.parse_packet(data)
    if msg:
        print(f"Received: {msg}")
        # Esempio di accesso ai dati
        if hasattr(msg, 'target_history'):
             print(f" -> Target History: {msg.target_history}")

dispatcher = MessageDispatcher()
net = UdpHandler()
net.register_callback(on_packet_received)
net.start()