Net module

PacketSocketEmitter

[Socket]({#ref classicy_1_1net_1_1Socket #}) adapter that emits received data as packets.

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

ReturnNameDescription
PacketFactoryfactoryThe packet factory.

factory

PacketFactory factory

The packet factory.

Public Methods

ReturnNameDescription
PacketSocketEmitterCreates the PacketSocketEmitter and attaches it to the given socket.
boolonSocketRecv virtualParses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop.
boolonPacket virtualProcess 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

  • socket Optional 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

  • socket The socket that received the data.

  • buffer The raw received data buffer.

  • peerAddress The 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.