#include <icy/net/packetsocket.h>Inherits:
SocketEmitter,Signal< void(IPacket &)>Subclassed by:Transaction< Message >,Transaction< PacketT >
Socket adapter that emits received data as packets.
| Return | Name | Description |
|---|---|---|
PacketFactory | factory | The packet factory. |
PacketFactory factoryThe packet factory.
| Return | Name | Description |
|---|---|---|
PacketSocketEmitter | Creates the PacketSocketEmitter and attaches it to the given socket. | |
bool | onSocketRecv virtual | Parses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop. |
bool | onPacket virtual | Process a parsed packet. Returns true to stop propagation. |
PacketSocketEmitter(const Socket::Ptr & socket)Creates the PacketSocketEmitter and attaches it to the given socket.
The emitter should be assigned a higher priority than plain socket adapters so that packet parsing occurs before generic data callbacks. Packets are created and dispatched using the registered factory strategies; strategies with the highest priority are tried first.
socket Optional socket to attach to immediately.virtual
virtual bool onSocketRecv(Socket & socket, const MutableBuffer & buffer, const Address & peerAddress)Parses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop.
socket The socket that received the data.
buffer The raw received data buffer.
peerAddress The sender's address.
true if the event was consumed and should not propagate further.
virtual
virtual bool onPacket(IPacket & pkt)Process a parsed packet. Returns true to stop propagation.