PacketSocketEmitter
PacketSocketEmitter
#include <icy/net/packetsocket.h>Inherits:
SocketEmitter,Signal< void(IPacket &)>Subclassed by:Transaction< Message >,Transaction< PacketT >
Socket adapter that emits received data as packets.
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketFactory | factory | The packet factory. |
factory
PacketFactory factoryThe packet factory.
Public Methods
| 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
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.
Parameters
socketOptional socket to attach to immediately.
onSocketRecv
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.
Parameters
socketThe socket that received the data.bufferThe raw received data buffer.peerAddressThe sender's address.
Returns
true if the event was consumed and should not propagate further.
onPacket
virtual
virtual bool onPacket(IPacket & pkt)Process a parsed packet. Returns true to stop propagation.
