Home
Net module

PacketSocketEmitter

Socket adapter that emits received data as packets.

PacketSocketEmitter

#include <icy/net/packetsocket.h>
class PacketSocketEmitter

Defined in src/net/include/icy/net/packetsocket.h:32

Inherits: SocketEmitter, Signal< void(IPacket &)> Subclassed by: Transaction< Message >, Transaction< PacketT >

Socket adapter that emits received data as packets.

List of all members

NameKindOwner
factoryvariableDeclared here
PacketSocketEmitterfunctionDeclared here
~PacketSocketEmitterfunctionDeclared here
onSocketRecvfunctionDeclared here
onPacketfunctionDeclared here
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtualSends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address.
functionsend virtual
functionsendOwned virtualSends an owned payload buffer to the connected peer.
functionsendOwned virtual
functionsendPacket virtualSends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address.
functionsendPacket virtual
functionsendPacket virtualSends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
PacketFactoryfactoryThe packet factory.

factory

PacketFactory factory

Defined in src/net/include/icy/net/packetsocket.h:59

The packet factory.

Public Methods

ReturnNameDescription
PacketSocketEmitterCreates the PacketSocketEmitter and attaches it to the given socket.
boolonSocketRecv virtual overrideParses 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 = nullptr)

Defined in src/net/include/icy/net/packetsocket.h:43

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 override

virtual bool onSocketRecv(Socket & socket, const MutableBuffer & buffer, const Address & peerAddress) override

Defined in src/net/include/icy/net/packetsocket.h:53

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.

Reimplements

onPacket

virtual

virtual bool onPacket(IPacket & pkt)

Defined in src/net/include/icy/net/packetsocket.h:56

Process a parsed packet. Returns true to stop propagation.

Reimplemented by