Dispatcher#
- class minecraft.networking.Dispatcher(connection)#
- dispatch(packet) None#
Dispatch a packet to the appropriate handlers.
- Parameters:
packet (Packet) – The packet to dispatch.
- register(packet: type[minecraft.packets.base.Packet], handler: Callable[[Packet], Coroutine]) None#
Register a handler for a packet.
- remove_handler(packet: type[minecraft.packets.base.Packet], handler: Callable[[Packet], Coroutine]) None#
Remove a handler for a packet.
- Parameters:
- Raises:
ValueError – The handler is not registered for the packet.
- async wait_for(packet: type[minecraft.packets.base.Packet], *, timeout=None) PACKET#
Wait for a packet to be received.
- Parameters:
- Returns:
The packet that was received.
- Return type:
- Raises:
asyncio.TimeoutError – The packet was not received before the timeout.