symple
May 15, 2026 ยท View on GitHub
{#symplemodule}
symple
Realtime messaging protocol for presence, rooms, and WebRTC signalling.
Namespaces
| Name | Description |
|---|---|
smpl | Symple protocol messages, peers, client, and server helpers. |
{#smpl}
smpl
Symple protocol messages, peers, client, and server helpers.
Classes
| Name | Description |
|---|---|
Client | Symple v4 client. |
Command | Symple command message with a node path and action verb. |
Event | Symple event message carrying a named occurrence with a timestamp. |
Form | Interactive form with pages, sections, and fields for command data exchange. |
FormElement | Base element within a Symple form. |
FormField | Form input field with typed values and selectable options. |
Message | Base Symple protocol message with addressing, status, data, and notes. |
Peer | Symple peer record containing identity, presence, and custom fields. |
Presence | Symple presence message indicating a peer's online status. |
Roster | The Roster provides a registry for active network peers indexed by session ID. |
Server | Symple v4 server. |
ServerPeer | Per-connection state for a connected Symple peer. |
Address | The Address structure is an endpoint identifier for a peer on the network. The format is like so: user|id |
ClientState | Client connection states. |
{#client-5}
Client
#include <icy/symple/client.h>
class Client
Defined in src/symple/include/icy/symple/client.h:88
Inherits:
Stateful< ClientState >,Signal< void(IPacket &)>
Symple v4 client.
Connects to a Symple server over plain WebSocket (no Socket.IO). Handles authentication, presence, roster management, rooms, and message routing.
Usage: smpl::Client client({ .host = "localhost", .port = 4500, .user = "alice", .name = "Alice" }); client.start();
client += packetSlot(&handler, &Handler::onMessage); client.Announce += slot(&handler, &Handler::onAnnounce);
Messages are emitted as polymorphic IPacket via PacketSignal:
-
smpl::Message (type "message")
-
smpl::Presence (type "presence")
-
smpl::Event (type "event")
-
smpl::Command (type "command")
Use packetSlot() with the specific type to filter.
List of all members
| Name | Kind | Owner |
|---|---|---|
Announce | variable | Declared here |
PeerConnected | variable | Declared here |
PeerDisconnected | variable | Declared here |
CreatePresence | variable | Declared here |
Client | function | Declared here |
Client | function | Declared here |
start | function | Declared here |
stop | function | Declared here |
send | function | Declared here |
send | function | Declared here |
respond | function | Declared here |
sendPresence | function | Declared here |
sendPresence | function | Declared here |
joinRoom | function | Declared here |
leaveRoom | function | Declared here |
isOnline | function | Declared here |
ourID | function | Declared here |
ourPeer | function | Declared here |
rooms | function | Declared here |
roster | function | Declared here |
options | function | Declared here |
setOptions | function | Declared here |
setError | function | Declared here |
createPresence | function | Declared here |
onPresenceData | function | Declared here |
_data | variable | Declared here |
doConnect | function | Declared here |
onTransportError | function | Declared here |
onSocketRecv | function | Declared here |
onSocketClose | function | Declared here |
onSocketError | function | Declared here |
onWelcome | function | Declared here |
onServerMessage | function | Declared here |
startReconnect | function | Declared here |
reset | function | Declared here |
syncDesiredRooms | function | Declared here |
sendJson | function | Declared here |
buildUrl | function | Declared here |
StateChange | variable | Inherited from Stateful |
_state | variable | Inherited from Stateful |
Stateful | function | Inherited from Stateful |
~Stateful | function | Inherited from Stateful |
stateEquals | function | Inherited from Stateful |
stateBetween | function | Inherited from Stateful |
state | function | Inherited from Stateful |
state | function | Inherited from Stateful |
beforeStateChange | function | Inherited from Stateful |
onStateChange | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
Inherited from Stateful
| Kind | Name | Description |
|---|---|---|
variable | StateChange | Signals when the state changes. |
variable | _state | |
function | Stateful inline | |
function | ~Stateful virtual inline | |
function | stateEquals virtual const inline | Returns true if the current state ID equals the given ID. |
function | stateBetween virtual const inline | Returns true if the current state ID is in the inclusive range [lid, rid]. |
function | state virtual inline | Returns a mutable reference to the current state. |
function | state virtual const inline | Returns a copy of the current state. |
function | beforeStateChange virtual inline | Override to handle pre state change logic. Return false to prevent state change. |
function | onStateChange virtual inline | Override to handle post state change logic. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
Public Attributes
| Return | Name | Description |
|---|---|---|
Signal< void(const int &)> | Announce | Authentication response status (200 = success, 401 = failed). |
Signal< void(Peer &)> | PeerConnected | A peer has come online. |
Signal< void(Peer &)> | PeerDisconnected | A peer has gone offline. |
Signal< void(Peer &)> | CreatePresence | Modify the outgoing peer object before presence broadcast. |
{#announce}
Announce
Signal< void(const int &)> Announce
Defined in src/symple/include/icy/symple/client.h:174
Authentication response status (200 = success, 401 = failed).
{#peerconnected}
PeerConnected
Signal< void(Peer &)> PeerConnected
Defined in src/symple/include/icy/symple/client.h:177
A peer has come online.
{#peerdisconnected}
PeerDisconnected
Signal< void(Peer &)> PeerDisconnected
Defined in src/symple/include/icy/symple/client.h:180
A peer has gone offline.
{#createpresence}
CreatePresence
Signal< void(Peer &)> CreatePresence
Defined in src/symple/include/icy/symple/client.h:183
Modify the outgoing peer object before presence broadcast.
Public Methods
| Return | Name | Description |
|---|---|---|
Client | ||
Client | Default constructor with default Options. | |
void | start | Start the Symple client. |
void | stop | Stop the Symple client. |
ssize_t | send virtual | Send a Symple message. Sets the from field automatically. |
ssize_t | send virtual | Send a string message (parsed as JSON). |
ssize_t | respond virtual | Swap to/from and send. |
ssize_t | sendPresence virtual | Broadcast presence to joined rooms. |
ssize_t | sendPresence virtual | Send directed presence to a specific peer. |
int | joinRoom virtual | Join a room on the server. |
int | leaveRoom virtual | Leave a room on the server. |
bool | isOnline const nodiscard | Return true if in Online state. |
std::string | ourID const nodiscard | Return the session ID assigned by the server. |
Peer * | ourPeer nodiscard | Return the local peer object (null if offline). |
StringVec | rooms const nodiscard | Return joined rooms. |
Roster & | roster nodiscard | Return the roster of online peers. |
const Options & | options const nodiscard | Return the current client options. |
void | setOptions | Replace the client options while the client is closed. This is the only supported way to reconfigure a default-constructed client. |
void | setError | Set an error and transition to Error state. |
{#client-6}
Client
Client(const Options & options, uv::Loop * loop = uv::defaultLoop())
Defined in src/symple/include/icy/symple/client.h:110
{#client-7}
Client
Client()
Defined in src/symple/include/icy/symple/client.h:112
Default constructor with default Options.
{#start-16}
start
void start()
Defined in src/symple/include/icy/symple/client.h:116
Start the Symple client.
{#stop-13}
stop
void stop()
Defined in src/symple/include/icy/symple/client.h:119
Stop the Symple client.
{#send-17}
send
virtual
virtual ssize_t send(Message & message)
Defined in src/symple/include/icy/symple/client.h:123
Send a Symple message. Sets the from field automatically.
{#send-18}
send
virtual
virtual ssize_t send(const std::string & message)
Defined in src/symple/include/icy/symple/client.h:126
Send a string message (parsed as JSON).
{#respond-1}
respond
virtual
virtual ssize_t respond(Message & message)
Defined in src/symple/include/icy/symple/client.h:129
Swap to/from and send.
{#sendpresence}
sendPresence
virtual
virtual ssize_t sendPresence(bool probe = false)
Defined in src/symple/include/icy/symple/client.h:132
Broadcast presence to joined rooms.
{#sendpresence-1}
sendPresence
virtual
virtual ssize_t sendPresence(const Address & to, bool probe = false)
Defined in src/symple/include/icy/symple/client.h:135
Send directed presence to a specific peer.
{#joinroom}
joinRoom
virtual
virtual int joinRoom(const std::string & room)
Defined in src/symple/include/icy/symple/client.h:138
Join a room on the server.
{#leaveroom}
leaveRoom
virtual
virtual int leaveRoom(const std::string & room)
Defined in src/symple/include/icy/symple/client.h:141
Leave a room on the server.
{#isonline}
isOnline
const nodiscard
[[nodiscard]] bool isOnline() const
Defined in src/symple/include/icy/symple/client.h:144
Return true if in Online state.
{#ourid}
ourID
const nodiscard
[[nodiscard]] std::string ourID() const
Defined in src/symple/include/icy/symple/client.h:147
Return the session ID assigned by the server.
{#ourpeer}
ourPeer
nodiscard
[[nodiscard]] Peer * ourPeer()
Defined in src/symple/include/icy/symple/client.h:150
Return the local peer object (null if offline).
{#rooms}
rooms
const nodiscard
[[nodiscard]] StringVec rooms() const
Defined in src/symple/include/icy/symple/client.h:153
Return joined rooms.
{#roster}
roster
nodiscard
[[nodiscard]] Roster & roster()
Defined in src/symple/include/icy/symple/client.h:156
Return the roster of online peers.
{#options-12}
options
const nodiscard
[[nodiscard]] const Options & options() const
Defined in src/symple/include/icy/symple/client.h:159
Return the current client options.
{#setoptions}
setOptions
void setOptions(Options options)
Defined in src/symple/include/icy/symple/client.h:164
Replace the client options while the client is closed. This is the only supported way to reconfigure a default-constructed client.
Exceptions
std::logic_errorif the client is currently connecting, online, or reconnecting.
{#seterror-6}
setError
void setError(const std::string & error)
Defined in src/symple/include/icy/symple/client.h:167
Set an error and transition to Error state.
Protected Methods
| Return | Name | Description |
|---|---|---|
void | createPresence virtual | Underlying connection state changed. Inherits StateChange from Stateful |
void | onPresenceData virtual |
{#createpresence-1}
createPresence
virtual
virtual void createPresence(Presence & p)
Defined in src/symple/include/icy/symple/client.h:189
Underlying connection state changed. Inherits StateChange from Stateful
{#onpresencedata}
onPresenceData
virtual
virtual void onPresenceData(const json::Value & data, bool whiny = false)
Defined in src/symple/include/icy/symple/client.h:190
Private Attributes
| Return | Name | Description |
|---|---|---|
std::unique_ptr< ClientData > | _data |
{#_data-1}
_data
std::unique_ptr< ClientData > _data
Defined in src/symple/include/icy/symple/client.h:209
Private Methods
| Return | Name | Description |
|---|---|---|
void | doConnect | |
void | onTransportError | |
void | onSocketRecv | |
void | onSocketClose | |
void | onSocketError | |
void | onWelcome | |
void | onServerMessage | |
void | startReconnect | |
void | reset | |
void | syncDesiredRooms | |
ssize_t | sendJson | |
std::string | buildUrl const |
{#doconnect}
doConnect
void doConnect()
Defined in src/symple/include/icy/symple/client.h:195
{#ontransporterror}
onTransportError
void onTransportError(const icy::Error & error)
Defined in src/symple/include/icy/symple/client.h:196
{#onsocketrecv-9}
onSocketRecv
void onSocketRecv(const std::string & data)
Defined in src/symple/include/icy/symple/client.h:197
{#onsocketclose-6}
onSocketClose
void onSocketClose()
Defined in src/symple/include/icy/symple/client.h:198
{#onsocketerror-4}
onSocketError
void onSocketError(const std::string & error)
Defined in src/symple/include/icy/symple/client.h:199
{#onwelcome}
onWelcome
void onWelcome(const json::Value & msg)
Defined in src/symple/include/icy/symple/client.h:200
{#onservermessage}
onServerMessage
void onServerMessage(const json::Value & msg)
Defined in src/symple/include/icy/symple/client.h:201
{#startreconnect}
startReconnect
void startReconnect()
Defined in src/symple/include/icy/symple/client.h:202
{#reset-15}
reset
void reset()
Defined in src/symple/include/icy/symple/client.h:203
{#syncdesiredrooms}
syncDesiredRooms
void syncDesiredRooms()
Defined in src/symple/include/icy/symple/client.h:204
{#sendjson}
sendJson
ssize_t sendJson(const json::Value & msg)
Defined in src/symple/include/icy/symple/client.h:206
{#buildurl}
buildUrl
const
std::string buildUrl() const
Defined in src/symple/include/icy/symple/client.h:207
{#options-13}
Options
#include <icy/symple/client.h>
struct Options
Defined in src/symple/include/icy/symple/client.h:93
Connection and authentication options for the Symple client.
List of all members
| Name | Kind | Owner |
|---|---|---|
host | variable | Declared here |
port | variable | Declared here |
secure | variable | Declared here |
reconnection | variable | Declared here |
reconnectAttempts | variable | Declared here |
reconnectDelay | variable | Declared here |
user | variable | Declared here |
name | variable | Declared here |
type | variable | Declared here |
token | variable | Declared here |
Options | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | host | |
uint16_t | port | |
bool | secure | Use wss:// instead of ws://. |
bool | reconnection | Auto-reconnect on disconnect. |
int | reconnectAttempts | 0 = unlimited |
int | reconnectDelay | Milliseconds between retries. |
std::string | user | User identifier (required). |
std::string | name | Display name. |
std::string | type | Peer type. |
std::string | token | Auth token (optional). |
{#host-2}
host
std::string host = "127.0.0.1"
Defined in src/symple/include/icy/symple/client.h:95
{#port-2}
port
uint16_t port = 4500
Defined in src/symple/include/icy/symple/client.h:96
{#secure-1}
secure
bool secure = false
Defined in src/symple/include/icy/symple/client.h:97
Use wss:// instead of ws://.
{#reconnection}
reconnection
bool reconnection = true
Defined in src/symple/include/icy/symple/client.h:98
Auto-reconnect on disconnect.
{#reconnectattempts}
reconnectAttempts
int reconnectAttempts = 0
Defined in src/symple/include/icy/symple/client.h:99
0 = unlimited
{#reconnectdelay}
reconnectDelay
int reconnectDelay = 3000
Defined in src/symple/include/icy/symple/client.h:100
Milliseconds between retries.
{#user-1}
user
std::string user
Defined in src/symple/include/icy/symple/client.h:102
User identifier (required).
{#name-12}
name
std::string name
Defined in src/symple/include/icy/symple/client.h:103
Display name.
{#type-19}
type
std::string type
Defined in src/symple/include/icy/symple/client.h:104
Peer type.
{#token}
token
std::string token
Defined in src/symple/include/icy/symple/client.h:105
Auth token (optional).
Public Methods
| Return | Name | Description |
|---|---|---|
Options | Defaulted constructor. |
{#options-14}
Options
Options() = default
Defined in src/symple/include/icy/symple/client.h:107
Defaulted constructor.
{#clientdata}
ClientData
#include <src/symple/src/client/detail.h>
struct ClientData
Defined in src/symple/src/client/detail.h:13
List of all members
| Name | Kind | Owner |
|---|---|---|
options | variable | Declared here |
loop | variable | Declared here |
ws | variable | Declared here |
roster | variable | Declared here |
ourID | variable | Declared here |
currentRooms | variable | Declared here |
desiredRooms | variable | Declared here |
pendingJoins | variable | Declared here |
pendingLeaves | variable | Declared here |
announceStatus | variable | Declared here |
reconnectTimer | variable | Declared here |
reconnectCount | variable | Declared here |
wasOnline | variable | Declared here |
closing | variable | Declared here |
remoteShutdown | variable | Declared here |
ClientData | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
Options | options | |
uv::Loop * | loop | |
http::ClientConnection::Ptr | ws | |
Roster | roster | |
std::string | ourID | |
std::unordered_set< std::string > | currentRooms | Authoritative rooms from welcome / acks. |
std::unordered_set< std::string > | desiredRooms | Rooms the client wants persisted across reconnects. |
std::unordered_set< std::string > | pendingJoins | Join requests sent but not yet acknowledged. |
std::unordered_set< std::string > | pendingLeaves | Leave requests sent but not yet acknowledged. |
int | announceStatus | |
Timer | reconnectTimer | |
int | reconnectCount | |
bool | wasOnline | |
bool | closing | |
bool | remoteShutdown |
{#options-15}
options
Options options
Defined in src/symple/src/client/detail.h:22
{#loop-8}
loop
uv::Loop * loop
Defined in src/symple/src/client/detail.h:23
{#ws-1}
ws
http::ClientConnection::Ptr ws
Defined in src/symple/src/client/detail.h:24
{#roster-1}
roster
Roster roster
Defined in src/symple/src/client/detail.h:25
{#ourid-1}
ourID
std::string ourID
Defined in src/symple/src/client/detail.h:26
{#currentrooms}
currentRooms
std::unordered_set< std::string > currentRooms
Defined in src/symple/src/client/detail.h:27
Authoritative rooms from welcome / acks.
{#desiredrooms}
desiredRooms
std::unordered_set< std::string > desiredRooms
Defined in src/symple/src/client/detail.h:28
Rooms the client wants persisted across reconnects.
{#pendingjoins}
pendingJoins
std::unordered_set< std::string > pendingJoins
Defined in src/symple/src/client/detail.h:29
Join requests sent but not yet acknowledged.
{#pendingleaves}
pendingLeaves
std::unordered_set< std::string > pendingLeaves
Defined in src/symple/src/client/detail.h:30
Leave requests sent but not yet acknowledged.
{#announcestatus}
announceStatus
int announceStatus = 0
Defined in src/symple/src/client/detail.h:31
{#reconnecttimer}
reconnectTimer
Timer reconnectTimer
Defined in src/symple/src/client/detail.h:32
{#reconnectcount}
reconnectCount
int reconnectCount = 0
Defined in src/symple/src/client/detail.h:33
{#wasonline}
wasOnline
bool wasOnline = false
Defined in src/symple/src/client/detail.h:34
{#closing-2}
closing
bool closing = false
Defined in src/symple/src/client/detail.h:35
{#remoteshutdown}
remoteShutdown
bool remoteShutdown = false
Defined in src/symple/src/client/detail.h:36
Public Methods
| Return | Name | Description |
|---|---|---|
ClientData inline explicit |
{#clientdata-1}
ClientData
inline explicit
inline explicit ClientData(Options opts, uv::Loop * targetLoop)
Defined in src/symple/src/client/detail.h:15
{#command}
Command
#include <icy/symple/command.h>
class Command
Defined in src/symple/include/icy/symple/command.h:28
Inherits:
Message
Symple command message with a node path and action verb.
The [node](#node) field is a colon-delimited path (e.g. "camera:zoom:in"). Individual path segments can be retrieved with param().
List of all members
| Name | Kind | Owner |
|---|---|---|
Command | function | Declared here |
Command | function | Declared here |
Command | function | Declared here |
node | function | Declared here |
action | function | Declared here |
setNode | function | Declared here |
setAction | function | Declared here |
valid | function | Declared here |
param | function | Declared here |
params | function | Declared here |
matches | function | Declared here |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
clone | function | Inherited from Message |
valid | function | Inherited from Message |
clear | function | Inherited from Message |
clearData | function | Inherited from Message |
clearNotes | function | Inherited from Message |
type | function | Inherited from Message |
id | function | Inherited from Message |
to | function | Inherited from Message |
from | function | Inherited from Message |
toUser | function | Inherited from Message |
toId | function | Inherited from Message |
fromUser | function | Inherited from Message |
fromId | function | Inherited from Message |
status | function | Inherited from Message |
setType | function | Inherited from Message |
setTo | function | Inherited from Message |
setTo | function | Inherited from Message |
setTo | function | Inherited from Message |
setFrom | function | Inherited from Message |
setFrom | function | Inherited from Message |
setFrom | function | Inherited from Message |
setStatus | function | Inherited from Message |
notes | function | Inherited from Message |
setNote | function | Inherited from Message |
addNote | function | Inherited from Message |
data | function | Inherited from Message |
data | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
removeData | function | Inherited from Message |
hasData | function | Inherited from Message |
read | function | Inherited from Message |
read | function | Inherited from Message |
write | function | Inherited from Message |
isRequest | function | Inherited from Message |
size | function | Inherited from Message |
print | function | Inherited from Message |
className | function | Inherited from Message |
data | function | Inherited from Message |
hasData | function | Inherited from Message |
opaque | variable | Inherited from IPacket |
info | variable | Inherited from IPacket |
flags | variable | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
operator= | function | Inherited from IPacket |
clone | function | Inherited from IPacket |
~IPacket | function | Inherited from IPacket |
read | function | Inherited from IPacket |
write | function | Inherited from IPacket |
size | function | Inherited from IPacket |
hasData | function | Inherited from IPacket |
data | function | Inherited from IPacket |
constData | function | Inherited from IPacket |
className | function | Inherited from IPacket |
print | function | Inherited from IPacket |
operator<< | friend | Inherited from IPacket |
Inherited from Message
| Kind | Name | Description |
|---|---|---|
function | Message | Constructs a new message with a random ID and type set to "message". |
function | Message | Constructs a message from a JSON value; sets missing id/type fields. |
function | Message | Copy constructor; preserves or generates id/type fields. |
function | clone virtual const override | Returns a heap-allocated copy of this message. |
function | valid virtual const | Returns true if the message has both [type](#type-22) and [id](#id-7) fields. |
function | clear virtual | Clears all JSON fields from this message. |
function | clearData virtual | Clears the [data](#data-4) sub-object. |
function | clearNotes virtual | Clears the [notes](#notes) array. |
function | type const nodiscard | Returns the message type string (defaults to "message"). |
function | id const nodiscard | Returns the message ID string. |
function | to const nodiscard | Returns the recipient address parsed from the [to](#to) field. |
function | from const nodiscard | Returns the sender address parsed from the [from](#from) field. |
function | toUser const nodiscard | Returns the user component of the [to](#to) address without constructing an Address. |
function | toId const nodiscard | Returns the id component of the [to](#to) address without constructing an Address. |
function | fromUser const nodiscard | Returns the user component of the [from](#from) address without constructing an Address. |
function | fromId const nodiscard | Returns the id component of the [from](#from) address without constructing an Address. |
function | status const nodiscard | Returns the HTTP status code, or -1 if not set. |
function | setType | Sets the message type field. |
function | setTo | Sets the [to](#to) field from a peer's address. |
function | setTo | Sets the [to](#to) field from an address object. |
function | setTo | Sets the [to](#to) field from an address string. |
function | setFrom | Sets the [from](#from) field from a peer's address. |
function | setFrom | Sets the [from](#from) field from an address object. |
function | setFrom | Sets the [from](#from) field from an address string. |
function | setStatus | HTTP status codes are used to describe the message response. Throws std::invalid_argument if code is outside [101, 504]. |
function | notes | Returns a reference to the [notes](#notes) JSON array. |
function | setNote | Replaces all notes with a single note. |
function | addNote | Appends a note to the [notes](#notes) array. |
function | data const | Returns a copy of the named data field. |
function | data | Returns a reference to the named data field (creates it if absent). |
function | setData | Creates or replaces a named data field; returns a reference to it. |
function | setData | Sets a named data field to a C-string value. |
function | setData | Sets a named data field to a string value. |
function | setData | Sets a named data field to a JSON value. |
function | setData | Sets a named data field to an integer value. |
function | removeData | Removes a named field from the [data](#data-4) sub-object. |
function | hasData | Returns true if the named field exists in the [data](#data-4) sub-object. |
function | read virtual override | Deserialises the message from a raw buffer. |
function | read virtual | Deserialises the message from a JSON string. |
function | write virtual const override | Serialises the message as JSON into a buffer. |
function | isRequest const nodiscard | Returns true if no status code has been set (i.e. status() == -1). |
function | size virtual const override | Returns the serialised JSON size in bytes. |
function | print virtual const override | Pretty-prints the message JSON to the given stream. |
function | className virtual const inline override | Returns the class name of this packet type for logging and diagnostics. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
Inherited from IPacket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime. |
variable | info | Optional extra information about the packet. |
variable | flags | Provides basic information about the packet. |
function | IPacket inline | |
function | IPacket inline | Copy constructor; clones the info object if present. |
function | operator= inline | Copy assignment; clones the info object if present. |
function | clone virtual const | Returns a heap-allocated deep copy of this packet. |
function | ~IPacket virtual | Defaulted destructor. |
function | read virtual | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
function | write virtual const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
function | size virtual const inline | The size of the packet in bytes. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | constData virtual const inline | The const packet data pointer for buffered packets. |
function | className virtual const | Returns the class name of this packet type for logging and diagnostics. |
function | print virtual const inline | Prints a human-readable representation to the given stream. |
friend | operator<< inline | Stream insertion operator; delegates to print(). |
Public Methods
| Return | Name | Description |
|---|---|---|
Command | Constructs an empty command with type set to "command". | |
Command | Constructs a command from a JSON value. | |
Command | Copy constructor. | |
std::string | node const nodiscard | Returns the colon-delimited node path (e.g. "camera:zoom"). |
std::string | action const nodiscard | Returns the action verb (defaults to "execute"). |
void | setNode | Sets the node path field. |
void | setAction | Sets the action verb field. |
bool | valid virtual const | Returns true if the base message is valid and the [node](#node) field is set. |
std::string | param const nodiscard | Returns the nth colon-separated segment of the node path (1-based). Throws std::out_of_range if n exceeds the number of segments. |
std::vector< std::string > | params | Returns all colon-separated segments of the node path. |
bool | matches const nodiscard | Returns true if the node path matches the given pattern. Uses wildcard node matching via util::matchNodes. |
{#command-1}
Command
Command()
Defined in src/symple/include/icy/symple/command.h:32
Constructs an empty command with type set to "command".
{#command-2}
Command
Command(const json::Value & root)
Defined in src/symple/include/icy/symple/command.h:36
Constructs a command from a JSON value.
Parameters
rootJSON object to initialise from.
{#command-3}
Command
Command(const Command & root)
Defined in src/symple/include/icy/symple/command.h:40
Copy constructor.
Parameters
rootSource command.
{#node}
node
const nodiscard
[[nodiscard]] std::string node() const
Defined in src/symple/include/icy/symple/command.h:45
Returns the colon-delimited node path (e.g. "camera:zoom").
{#action-2}
action
const nodiscard
[[nodiscard]] std::string action() const
Defined in src/symple/include/icy/symple/command.h:48
Returns the action verb (defaults to "execute").
{#setnode}
setNode
void setNode(std::string_view node)
Defined in src/symple/include/icy/symple/command.h:52
Sets the node path field.
Parameters
nodeColon-delimited node path string.
{#setaction}
setAction
void setAction(std::string_view action)
Defined in src/symple/include/icy/symple/command.h:56
Sets the action verb field.
Parameters
actionAction string (e.g. "execute", "get", "set").
{#valid-11}
valid
virtual const
virtual bool valid() const
Defined in src/symple/include/icy/symple/command.h:59
Returns true if the base message is valid and the [node](#node) field is set.
Reimplements
{#param}
param
const nodiscard
[[nodiscard]] std::string param(int n) const
Defined in src/symple/include/icy/symple/command.h:65
Returns the nth colon-separated segment of the node path (1-based). Throws std::out_of_range if n exceeds the number of segments.
Parameters
n1-based segment index.
Returns
The nth path segment.
{#params}
params
std::vector< std::string > params()
Defined in src/symple/include/icy/symple/command.h:69
Returns all colon-separated segments of the node path.
Returns
Vector of path segment strings.
{#matches-3}
matches
const nodiscard
[[nodiscard]] bool matches(std::string_view xnode) const
Defined in src/symple/include/icy/symple/command.h:74
Returns true if the node path matches the given pattern. Uses wildcard node matching via util::matchNodes.
Parameters
xnodePattern to match against (colon-delimited, supports wildcards).
{#event-2}
Event
#include <icy/symple/event.h>
class Event
Defined in src/symple/include/icy/symple/event.h:29
Inherits:
Message
Symple event message carrying a named occurrence with a timestamp.
The [name](#name-13) field identifies the event. The [time](base.md#time-3) field is stored as a Unix timestamp (seconds since epoch).
List of all members
| Name | Kind | Owner |
|---|---|---|
Event | function | Declared here |
Event | function | Declared here |
Event | function | Declared here |
valid | function | Declared here |
name | function | Declared here |
time | function | Declared here |
setName | function | Declared here |
setTime | function | Declared here |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
clone | function | Inherited from Message |
valid | function | Inherited from Message |
clear | function | Inherited from Message |
clearData | function | Inherited from Message |
clearNotes | function | Inherited from Message |
type | function | Inherited from Message |
id | function | Inherited from Message |
to | function | Inherited from Message |
from | function | Inherited from Message |
toUser | function | Inherited from Message |
toId | function | Inherited from Message |
fromUser | function | Inherited from Message |
fromId | function | Inherited from Message |
status | function | Inherited from Message |
setType | function | Inherited from Message |
setTo | function | Inherited from Message |
setTo | function | Inherited from Message |
setTo | function | Inherited from Message |
setFrom | function | Inherited from Message |
setFrom | function | Inherited from Message |
setFrom | function | Inherited from Message |
setStatus | function | Inherited from Message |
notes | function | Inherited from Message |
setNote | function | Inherited from Message |
addNote | function | Inherited from Message |
data | function | Inherited from Message |
data | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
removeData | function | Inherited from Message |
hasData | function | Inherited from Message |
read | function | Inherited from Message |
read | function | Inherited from Message |
write | function | Inherited from Message |
isRequest | function | Inherited from Message |
size | function | Inherited from Message |
print | function | Inherited from Message |
className | function | Inherited from Message |
data | function | Inherited from Message |
hasData | function | Inherited from Message |
opaque | variable | Inherited from IPacket |
info | variable | Inherited from IPacket |
flags | variable | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
operator= | function | Inherited from IPacket |
clone | function | Inherited from IPacket |
~IPacket | function | Inherited from IPacket |
read | function | Inherited from IPacket |
write | function | Inherited from IPacket |
size | function | Inherited from IPacket |
hasData | function | Inherited from IPacket |
data | function | Inherited from IPacket |
constData | function | Inherited from IPacket |
className | function | Inherited from IPacket |
print | function | Inherited from IPacket |
operator<< | friend | Inherited from IPacket |
Inherited from Message
| Kind | Name | Description |
|---|---|---|
function | Message | Constructs a new message with a random ID and type set to "message". |
function | Message | Constructs a message from a JSON value; sets missing id/type fields. |
function | Message | Copy constructor; preserves or generates id/type fields. |
function | clone virtual const override | Returns a heap-allocated copy of this message. |
function | valid virtual const | Returns true if the message has both [type](#type-22) and [id](#id-7) fields. |
function | clear virtual | Clears all JSON fields from this message. |
function | clearData virtual | Clears the [data](#data-4) sub-object. |
function | clearNotes virtual | Clears the [notes](#notes) array. |
function | type const nodiscard | Returns the message type string (defaults to "message"). |
function | id const nodiscard | Returns the message ID string. |
function | to const nodiscard | Returns the recipient address parsed from the [to](#to) field. |
function | from const nodiscard | Returns the sender address parsed from the [from](#from) field. |
function | toUser const nodiscard | Returns the user component of the [to](#to) address without constructing an Address. |
function | toId const nodiscard | Returns the id component of the [to](#to) address without constructing an Address. |
function | fromUser const nodiscard | Returns the user component of the [from](#from) address without constructing an Address. |
function | fromId const nodiscard | Returns the id component of the [from](#from) address without constructing an Address. |
function | status const nodiscard | Returns the HTTP status code, or -1 if not set. |
function | setType | Sets the message type field. |
function | setTo | Sets the [to](#to) field from a peer's address. |
function | setTo | Sets the [to](#to) field from an address object. |
function | setTo | Sets the [to](#to) field from an address string. |
function | setFrom | Sets the [from](#from) field from a peer's address. |
function | setFrom | Sets the [from](#from) field from an address object. |
function | setFrom | Sets the [from](#from) field from an address string. |
function | setStatus | HTTP status codes are used to describe the message response. Throws std::invalid_argument if code is outside [101, 504]. |
function | notes | Returns a reference to the [notes](#notes) JSON array. |
function | setNote | Replaces all notes with a single note. |
function | addNote | Appends a note to the [notes](#notes) array. |
function | data const | Returns a copy of the named data field. |
function | data | Returns a reference to the named data field (creates it if absent). |
function | setData | Creates or replaces a named data field; returns a reference to it. |
function | setData | Sets a named data field to a C-string value. |
function | setData | Sets a named data field to a string value. |
function | setData | Sets a named data field to a JSON value. |
function | setData | Sets a named data field to an integer value. |
function | removeData | Removes a named field from the [data](#data-4) sub-object. |
function | hasData | Returns true if the named field exists in the [data](#data-4) sub-object. |
function | read virtual override | Deserialises the message from a raw buffer. |
function | read virtual | Deserialises the message from a JSON string. |
function | write virtual const override | Serialises the message as JSON into a buffer. |
function | isRequest const nodiscard | Returns true if no status code has been set (i.e. status() == -1). |
function | size virtual const override | Returns the serialised JSON size in bytes. |
function | print virtual const override | Pretty-prints the message JSON to the given stream. |
function | className virtual const inline override | Returns the class name of this packet type for logging and diagnostics. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
Inherited from IPacket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime. |
variable | info | Optional extra information about the packet. |
variable | flags | Provides basic information about the packet. |
function | IPacket inline | |
function | IPacket inline | Copy constructor; clones the info object if present. |
function | operator= inline | Copy assignment; clones the info object if present. |
function | clone virtual const | Returns a heap-allocated deep copy of this packet. |
function | ~IPacket virtual | Defaulted destructor. |
function | read virtual | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
function | write virtual const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
function | size virtual const inline | The size of the packet in bytes. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | constData virtual const inline | The const packet data pointer for buffered packets. |
function | className virtual const | Returns the class name of this packet type for logging and diagnostics. |
function | print virtual const inline | Prints a human-readable representation to the given stream. |
friend | operator<< inline | Stream insertion operator; delegates to print(). |
Public Methods
| Return | Name | Description |
|---|---|---|
Event | Constructs an event with type "event" and time set to now. | |
Event | Constructs an event from a JSON value; sets missing time to now. | |
Event | Copy constructor; preserves or sets missing time to now. | |
bool | valid virtual const nodiscard | Returns true if the base message is valid and the [name](#name-13) field is set. |
std::string | name const nodiscard | Returns the event name string. |
std::time_t | time const nodiscard | Returns the event timestamp as a Unix time_t value. |
void | setName | Sets the event name field. |
void | setTime | Sets the event timestamp. |
{#event-3}
Event
Event()
Defined in src/symple/include/icy/symple/event.h:33
Constructs an event with type "event" and time set to now.
{#event-4}
Event
Event(const json::Value & root)
Defined in src/symple/include/icy/symple/event.h:37
Constructs an event from a JSON value; sets missing time to now.
Parameters
rootJSON object to initialise from.
{#event-5}
Event
Event(const Event & root)
Defined in src/symple/include/icy/symple/event.h:41
Copy constructor; preserves or sets missing time to now.
Parameters
rootSource event.
{#valid-12}
valid
virtual const nodiscard
[[nodiscard]] virtual bool valid() const
Defined in src/symple/include/icy/symple/event.h:46
Returns true if the base message is valid and the [name](#name-13) field is set.
Reimplements
{#name-13}
name
const nodiscard
[[nodiscard]] std::string name() const
Defined in src/symple/include/icy/symple/event.h:49
Returns the event name string.
{#time-4}
time
const nodiscard
[[nodiscard]] std::time_t time() const
Defined in src/symple/include/icy/symple/event.h:53
Returns the event timestamp as a Unix time_t value.
{#setname-2}
setName
void setName(std::string_view name)
Defined in src/symple/include/icy/symple/event.h:57
Sets the event name field.
Parameters
nameEvent name string.
{#settime}
setTime
void setTime(std::time_t time)
Defined in src/symple/include/icy/symple/event.h:62
Sets the event timestamp.
Parameters
timeUnix timestamp (seconds since epoch).
{#form}
Form
#include <icy/symple/form.h>
class Form
Defined in src/symple/include/icy/symple/form.h:178
Inherits:
FormElement
Interactive form with pages, sections, and fields for command data exchange.
Attach a Form to a Command message to carry structured input/output. The [action](#action-3) field governs the exchange direction; [partial](#partial) enables live/auto-complete field submission.
List of all members
| Name | Kind | Owner |
|---|---|---|
Form | function | Declared here |
Form | function | Declared here |
Form | function | Declared here |
valid | function | Declared here |
action | function | Declared here |
partial | function | Declared here |
setAction | function | Declared here |
setPartial | function | Declared here |
FormElement | function | Inherited from FormElement |
FormElement | function | Inherited from FormElement |
FormElement | function | Inherited from FormElement |
operator= | function | Inherited from FormElement |
type | function | Inherited from FormElement |
id | function | Inherited from FormElement |
label | function | Inherited from FormElement |
setType | function | Inherited from FormElement |
setId | function | Inherited from FormElement |
setLabel | function | Inherited from FormElement |
setHint | function | Inherited from FormElement |
setError | function | Inherited from FormElement |
addPage | function | Inherited from FormElement |
addSection | function | Inherited from FormElement |
addField | function | Inherited from FormElement |
getField | function | Inherited from FormElement |
getField | function | Inherited from FormElement |
hasField | function | Inherited from FormElement |
setLive | function | Inherited from FormElement |
live | function | Inherited from FormElement |
clearElements | function | Inherited from FormElement |
clear | function | Inherited from FormElement |
valid | function | Inherited from FormElement |
numElements | function | Inherited from FormElement |
hasErrors | function | Inherited from FormElement |
hasPages | function | Inherited from FormElement |
root | function | Inherited from FormElement |
_root | variable | Inherited from FormElement |
Inherited from FormElement
| Kind | Name | Description |
|---|---|---|
function | FormElement | Constructs an unbound element (root pointer is null). |
function | FormElement | Constructs an element bound to the given JSON node. |
function | FormElement | Copy constructor; copies the root pointer reference (shallow). |
function | operator= | Copy-assigns the root pointer reference. |
function | type const nodiscard | Returns the element type string. |
function | id const nodiscard | Returns the element ID string. |
function | label const nodiscard | Returns the display label string. |
function | setType | Sets the element type. Possible values: page, section, text, text-multi, list, list-multi, checkbox, media, custom |
function | setId | Sets the element ID field. |
function | setLabel | Sets the display label field. |
function | setHint | Sets the hint/description field shown below the element. |
function | setError | Sets an optional validation error message. |
function | addPage | Appends a page child element and returns a handle to it. |
function | addSection | Appends a section child element and returns a handle to it. |
function | addField | Appends a typed field child element and returns a handle to it. Throws std::invalid_argument if type is not a recognised field type. |
function | getField | Searches child elements for the field with the given ID. |
function | getField | Populates a FormField by searching child elements for the given ID. |
function | hasField | Returns true if any child element has an ID matching the given value. |
function | setLive | Sets the live flag on this element. Live elements are used to submit partial form sections (e.g. for auto-complete) without sending the entire form. |
function | live const nodiscard | Returns true if this field is live, meaning the form-processing entity should auto-update this field's value whenever it changes. |
function | clearElements | Removes all child elements whose ID matches the given value. |
function | clear | Clears all fields from the underlying JSON node. |
function | valid const nodiscard | Returns true if the form element is valid. |
function | numElements | Returns the number of child elements. |
function | hasErrors | Returns true if any fields have errors. |
function | hasPages | Returns true if the form has multiple pages. |
function | root const nodiscard | Returns a reference to the underlying JSON node. Throws std::runtime_error if the root pointer is null. |
variable | _root | The root pointer is just a reference to the externally managed JSON value memory. |
Public Methods
| Return | Name | Description |
|---|---|---|
Form | Constructs an unbound form (root pointer is null). | |
Form | Constructs a form bound to the given JSON node. Sets the [type](#type-21) field to "form". | |
Form | Constructs a form from a Command, binding to command["form"]. Sets the [type](#type-21) field to "form". | |
bool | valid | Returns true if the element is valid, non-empty, and has no errors. |
std::string | action const nodiscard | Returns the form action string (defaults to "form"). |
bool | partial const nodiscard | Returns true if this is a partial form submission. |
void | setAction | Sets the form action field. Throws std::invalid_argument for unrecognised values. Possible values: form - Form-processing entity requests form completion. submit - Form-submitting entity is sending data. cancel - Form-submitting entity cancelled submission. result - Form-processing entity is returning data. |
void | setPartial | Marks the form as a partial section for live/auto-complete updates. Partial forms transmit only the changed fields rather than the entire form payload. |
{#form-1}
Form
Form()
Defined in src/symple/include/icy/symple/form.h:182
Constructs an unbound form (root pointer is null).
{#form-2}
Form
Form(json::Value & root)
Defined in src/symple/include/icy/symple/form.h:187
Constructs a form bound to the given JSON node. Sets the [type](#type-21) field to "form".
Parameters
rootJSON node to bind to.
{#form-3}
Form
Form(Command & root)
Defined in src/symple/include/icy/symple/form.h:192
Constructs a form from a Command, binding to command["form"]. Sets the [type](#type-21) field to "form".
Parameters
rootParent command message.
{#valid-13}
valid
bool valid()
Defined in src/symple/include/icy/symple/form.h:197
Returns true if the element is valid, non-empty, and has no errors.
{#action-3}
action
const nodiscard
[[nodiscard]] std::string action() const
Defined in src/symple/include/icy/symple/form.h:200
Returns the form action string (defaults to "form").
{#partial}
partial
const nodiscard
[[nodiscard]] bool partial() const
Defined in src/symple/include/icy/symple/form.h:203
Returns true if this is a partial form submission.
{#setaction-1}
setAction
void setAction(std::string_view action)
Defined in src/symple/include/icy/symple/form.h:213
Sets the form action field. Throws std::invalid_argument for unrecognised values. Possible values: form - Form-processing entity requests form completion. submit - Form-submitting entity is sending data. cancel - Form-submitting entity cancelled submission. result - Form-processing entity is returning data.
Parameters
actionAction string.
{#setpartial}
setPartial
void setPartial(bool flag)
Defined in src/symple/include/icy/symple/form.h:219
Marks the form as a partial section for live/auto-complete updates. Partial forms transmit only the changed fields rather than the entire form payload.
Parameters
flagTrue to mark as partial.
{#formelement}
FormElement
#include <icy/symple/form.h>
class FormElement
Defined in src/symple/include/icy/symple/form.h:33
Base element within a Symple form.
FormElement wraps a reference to an external JSON node and provides typed accessors for the common [type](#type-21), [id](#id-6), [label](#label), and elements fields. Pages, sections, and fields all derive from this base.
List of all members
| Name | Kind | Owner |
|---|---|---|
FormElement | function | Declared here |
FormElement | function | Declared here |
FormElement | function | Declared here |
operator= | function | Declared here |
type | function | Declared here |
id | function | Declared here |
label | function | Declared here |
setType | function | Declared here |
setId | function | Declared here |
setLabel | function | Declared here |
setHint | function | Declared here |
setError | function | Declared here |
addPage | function | Declared here |
addSection | function | Declared here |
addField | function | Declared here |
getField | function | Declared here |
getField | function | Declared here |
hasField | function | Declared here |
setLive | function | Declared here |
live | function | Declared here |
clearElements | function | Declared here |
clear | function | Declared here |
valid | function | Declared here |
numElements | function | Declared here |
hasErrors | function | Declared here |
hasPages | function | Declared here |
root | function | Declared here |
_root | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
FormElement | Constructs an unbound element (root pointer is null). | |
FormElement | Constructs an element bound to the given JSON node. | |
FormElement | Copy constructor; copies the root pointer reference (shallow). | |
FormElement & | operator= | Copy-assigns the root pointer reference. |
std::string | type const nodiscard | Returns the element type string. |
std::string | id const nodiscard | Returns the element ID string. |
std::string | label const nodiscard | Returns the display label string. |
void | setType | Sets the element type. Possible values: page, section, text, text-multi, list, list-multi, checkbox, media, custom |
void | setId | Sets the element ID field. |
void | setLabel | Sets the display label field. |
void | setHint | Sets the hint/description field shown below the element. |
void | setError | Sets an optional validation error message. |
FormElement | addPage | Appends a page child element and returns a handle to it. |
FormElement | addSection | Appends a section child element and returns a handle to it. |
FormField | addField | Appends a typed field child element and returns a handle to it. Throws std::invalid_argument if type is not a recognised field type. |
FormField | getField | Searches child elements for the field with the given ID. |
bool | getField | Populates a FormField by searching child elements for the given ID. |
bool | hasField | Returns true if any child element has an ID matching the given value. |
void | setLive | Sets the live flag on this element. Live elements are used to submit partial form sections (e.g. for auto-complete) without sending the entire form. |
bool | live const nodiscard | Returns true if this field is live, meaning the form-processing entity should auto-update this field's value whenever it changes. |
bool | clearElements | Removes all child elements whose ID matches the given value. |
void | clear | Clears all fields from the underlying JSON node. |
bool | valid const nodiscard | Returns true if the form element is valid. |
int | numElements | Returns the number of child elements. |
bool | hasErrors | Returns true if any fields have errors. |
bool | hasPages | Returns true if the form has multiple pages. |
json::Value & | root const nodiscard | Returns a reference to the underlying JSON node. Throws std::runtime_error if the root pointer is null. |
{#formelement-1}
FormElement
FormElement()
Defined in src/symple/include/icy/symple/form.h:37
Constructs an unbound element (root pointer is null).
{#formelement-2}
FormElement
FormElement(json::Value & root, std::string_view type = "", std::string_view id = "", std::string_view label = "")
Defined in src/symple/include/icy/symple/form.h:44
Constructs an element bound to the given JSON node.
Parameters
-
rootJSON node this element refers to. -
typeOptional element type string. -
idOptional element ID string. -
labelOptional display label string.
{#formelement-3}
FormElement
FormElement(const FormElement & r)
Defined in src/symple/include/icy/symple/form.h:49
Copy constructor; copies the root pointer reference (shallow).
Parameters
rSource element.
{#operator-37}
operator=
FormElement & operator=(const FormElement & r)
Defined in src/symple/include/icy/symple/form.h:53
Copy-assigns the root pointer reference.
Parameters
rSource element.
{#type-21}
type
const nodiscard
[[nodiscard]] std::string type() const
Defined in src/symple/include/icy/symple/form.h:58
Returns the element type string.
{#id-6}
id
const nodiscard
[[nodiscard]] std::string id() const
Defined in src/symple/include/icy/symple/form.h:61
Returns the element ID string.
{#label}
label
const nodiscard
[[nodiscard]] std::string label() const
Defined in src/symple/include/icy/symple/form.h:64
Returns the display label string.
{#settype-1}
setType
void setType(std::string_view type)
Defined in src/symple/include/icy/symple/form.h:70
Sets the element type. Possible values: page, section, text, text-multi, list, list-multi, checkbox, media, custom
Parameters
typeElement type string.
{#setid}
setId
void setId(std::string_view id)
Defined in src/symple/include/icy/symple/form.h:74
Sets the element ID field.
Parameters
idElement ID string.
{#setlabel}
setLabel
void setLabel(std::string_view text)
Defined in src/symple/include/icy/symple/form.h:78
Sets the display label field.
Parameters
textLabel text.
{#sethint}
setHint
void setHint(std::string_view text)
Defined in src/symple/include/icy/symple/form.h:82
Sets the hint/description field shown below the element.
Parameters
textHint text.
{#seterror-7}
setError
void setError(std::string_view error)
Defined in src/symple/include/icy/symple/form.h:86
Sets an optional validation error message.
Parameters
errorError text to display.
{#addpage}
addPage
FormElement addPage(std::string_view id = "", std::string_view label = "")
Defined in src/symple/include/icy/symple/form.h:92
Appends a page child element and returns a handle to it.
Parameters
-
idOptional page ID. -
labelOptional page label.
Returns
FormElement referencing the new page node.
{#addsection}
addSection
FormElement addSection(std::string_view id = "", std::string_view label = "")
Defined in src/symple/include/icy/symple/form.h:99
Appends a section child element and returns a handle to it.
Parameters
-
idOptional section ID. -
labelOptional section label.
Returns
FormElement referencing the new section node.
{#addfield}
addField
FormField addField(std::string_view type, std::string_view id = "", std::string_view label = "")
Defined in src/symple/include/icy/symple/form.h:108
Appends a typed field child element and returns a handle to it. Throws std::invalid_argument if type is not a recognised field type.
Parameters
-
typeField type (e.g. "text", "list", "boolean"). -
idOptional field ID. -
labelOptional field label.
Returns
FormField referencing the new field node.
{#getfield}
getField
FormField getField(std::string_view id, bool partial = false)
Defined in src/symple/include/icy/symple/form.h:115
Searches child elements for the field with the given ID.
Parameters
-
idField ID to search for. -
partialIf true, performs a substring match.
Returns
FormField handle (may be invalid if not found).
{#getfield-1}
getField
bool getField(std::string_view id, FormField & field, bool partial = false)
Defined in src/symple/include/icy/symple/form.h:122
Populates a FormField by searching child elements for the given ID.
Parameters
-
idField ID to search for. -
fieldOutput field handle. -
partialIf true, performs a substring match.
Returns
True if the field was found.
{#hasfield}
hasField
bool hasField(std::string_view id, bool partial = false)
Defined in src/symple/include/icy/symple/form.h:128
Returns true if any child element has an ID matching the given value.
Parameters
-
idID string to search for. -
partialIf true, a substring match is sufficient.
{#setlive}
setLive
void setLive(bool flag)
Defined in src/symple/include/icy/symple/form.h:134
Sets the live flag on this element. Live elements are used to submit partial form sections (e.g. for auto-complete) without sending the entire form.
Parameters
flagTrue to enable live updates.
{#live}
live
const nodiscard
[[nodiscard]] bool live() const
Defined in src/symple/include/icy/symple/form.h:139
Returns true if this field is live, meaning the form-processing entity should auto-update this field's value whenever it changes.
{#clearelements}
clearElements
bool clearElements(std::string_view id, bool partial = false)
Defined in src/symple/include/icy/symple/form.h:145
Removes all child elements whose ID matches the given value.
Parameters
-
idID string to match against. -
partialIf true, removes elements whose ID contains the string.
Returns
True if at least one element was removed.
{#clear-3}
clear
void clear()
Defined in src/symple/include/icy/symple/form.h:148
Clears all fields from the underlying JSON node.
{#valid-14}
valid
const nodiscard
[[nodiscard]] bool valid() const
Defined in src/symple/include/icy/symple/form.h:151
Returns true if the form element is valid.
{#numelements}
numElements
int numElements()
Defined in src/symple/include/icy/symple/form.h:154
Returns the number of child elements.
{#haserrors}
hasErrors
bool hasErrors()
Defined in src/symple/include/icy/symple/form.h:157
Returns true if any fields have errors.
{#haspages}
hasPages
bool hasPages()
Defined in src/symple/include/icy/symple/form.h:160
Returns true if the form has multiple pages.
{#root-4}
root
const nodiscard
[[nodiscard]] json::Value & root() const
Defined in src/symple/include/icy/symple/form.h:164
Returns a reference to the underlying JSON node. Throws std::runtime_error if the root pointer is null.
Protected Attributes
| Return | Name | Description |
|---|---|---|
json::Value * | _root | The root pointer is just a reference to the externally managed JSON value memory. |
{#_root}
_root
json::Value * _root
Defined in src/symple/include/icy/symple/form.h:169
The root pointer is just a reference to the externally managed JSON value memory.
{#formfield}
FormField
#include <icy/symple/form.h>
class FormField
Defined in src/symple/include/icy/symple/form.h:227
Inherits:
FormElement
Form input field with typed values and selectable options.
Values are stored as strings in a JSON array. Typed accessors (intValue, doubleValue, boolValue) parse the first string on demand.
List of all members
| Name | Kind | Owner |
|---|---|---|
FormField | function | Declared here |
FormField | function | Declared here |
addOption | function | Declared here |
addOption | function | Declared here |
setValue | function | Declared here |
setValue | function | Declared here |
setValue | function | Declared here |
setValue | function | Declared here |
addValue | function | Declared here |
addValue | function | Declared here |
addValue | function | Declared here |
addValue | function | Declared here |
values | function | Declared here |
value | function | Declared here |
intValue | function | Declared here |
doubleValue | function | Declared here |
boolValue | function | Declared here |
FormElement | function | Inherited from FormElement |
FormElement | function | Inherited from FormElement |
FormElement | function | Inherited from FormElement |
operator= | function | Inherited from FormElement |
type | function | Inherited from FormElement |
id | function | Inherited from FormElement |
label | function | Inherited from FormElement |
setType | function | Inherited from FormElement |
setId | function | Inherited from FormElement |
setLabel | function | Inherited from FormElement |
setHint | function | Inherited from FormElement |
setError | function | Inherited from FormElement |
addPage | function | Inherited from FormElement |
addSection | function | Inherited from FormElement |
addField | function | Inherited from FormElement |
getField | function | Inherited from FormElement |
getField | function | Inherited from FormElement |
hasField | function | Inherited from FormElement |
setLive | function | Inherited from FormElement |
live | function | Inherited from FormElement |
clearElements | function | Inherited from FormElement |
clear | function | Inherited from FormElement |
valid | function | Inherited from FormElement |
numElements | function | Inherited from FormElement |
hasErrors | function | Inherited from FormElement |
hasPages | function | Inherited from FormElement |
root | function | Inherited from FormElement |
_root | variable | Inherited from FormElement |
Inherited from FormElement
| Kind | Name | Description |
|---|---|---|
function | FormElement | Constructs an unbound element (root pointer is null). |
function | FormElement | Constructs an element bound to the given JSON node. |
function | FormElement | Copy constructor; copies the root pointer reference (shallow). |
function | operator= | Copy-assigns the root pointer reference. |
function | type const nodiscard | Returns the element type string. |
function | id const nodiscard | Returns the element ID string. |
function | label const nodiscard | Returns the display label string. |
function | setType | Sets the element type. Possible values: page, section, text, text-multi, list, list-multi, checkbox, media, custom |
function | setId | Sets the element ID field. |
function | setLabel | Sets the display label field. |
function | setHint | Sets the hint/description field shown below the element. |
function | setError | Sets an optional validation error message. |
function | addPage | Appends a page child element and returns a handle to it. |
function | addSection | Appends a section child element and returns a handle to it. |
function | addField | Appends a typed field child element and returns a handle to it. Throws std::invalid_argument if type is not a recognised field type. |
function | getField | Searches child elements for the field with the given ID. |
function | getField | Populates a FormField by searching child elements for the given ID. |
function | hasField | Returns true if any child element has an ID matching the given value. |
function | setLive | Sets the live flag on this element. Live elements are used to submit partial form sections (e.g. for auto-complete) without sending the entire form. |
function | live const nodiscard | Returns true if this field is live, meaning the form-processing entity should auto-update this field's value whenever it changes. |
function | clearElements | Removes all child elements whose ID matches the given value. |
function | clear | Clears all fields from the underlying JSON node. |
function | valid const nodiscard | Returns true if the form element is valid. |
function | numElements | Returns the number of child elements. |
function | hasErrors | Returns true if any fields have errors. |
function | hasPages | Returns true if the form has multiple pages. |
function | root const nodiscard | Returns a reference to the underlying JSON node. Throws std::runtime_error if the root pointer is null. |
variable | _root | The root pointer is just a reference to the externally managed JSON value memory. |
Public Methods
| Return | Name | Description |
|---|---|---|
FormField | Constructs an unbound field (root pointer is null). | |
FormField | Constructs a field bound to the given JSON node. | |
void | addOption | Adds a labelled option for list-based fields. |
void | addOption | Adds an option whose key and display value are identical. |
void | setValue | Replaces all current values with a single string value. |
void | setValue | Replaces all current values with a single integer value. |
void | setValue | Replaces all current values with a single double value. |
void | setValue | Replaces all current values with a single boolean value. |
void | addValue | Appends a string value to the values array. |
void | addValue | Appends an integer value to the values array. |
void | addValue | Appends a double value to the values array. |
void | addValue | Appends a boolean value to the values array. |
json::Value & | values | Returns a reference to the JSON array of all values. |
std::string | value const nodiscard | Returns the first value as a string. Most field types (except multi-value) only use a single value. |
int | intValue const nodiscard | Returns the first value parsed as an integer. |
double | doubleValue const nodiscard | Returns the first value parsed as a double. |
bool | boolValue const nodiscard | Returns the first value parsed as a boolean. Treats "1", "true", and "on" as true; all other strings as false. |
{#formfield-1}
FormField
FormField()
Defined in src/symple/include/icy/symple/form.h:231
Constructs an unbound field (root pointer is null).
{#formfield-2}
FormField
FormField(json::Value & root, std::string_view type = "", std::string_view id = "", std::string_view label = "")
Defined in src/symple/include/icy/symple/form.h:238
Constructs a field bound to the given JSON node.
Parameters
-
rootJSON node to bind to. -
typeField type string (e.g. "text", "list"). -
idOptional field ID. -
labelOptional display label.
{#addoption}
addOption
void addOption(std::string_view key, std::string_view value)
Defined in src/symple/include/icy/symple/form.h:245
Adds a labelled option for list-based fields.
Parameters
-
keyOption key sent on submit. -
valueDisplay label for the option.
{#addoption-1}
addOption
void addOption(std::string_view value)
Defined in src/symple/include/icy/symple/form.h:249
Adds an option whose key and display value are identical.
Parameters
valueOption string.
{#setvalue-4}
setValue
void setValue(std::string_view value)
Defined in src/symple/include/icy/symple/form.h:253
Replaces all current values with a single string value.
Parameters
valueString value to set.
{#setvalue-5}
setValue
void setValue(int value)
Defined in src/symple/include/icy/symple/form.h:257
Replaces all current values with a single integer value.
Parameters
valueInteger value to set.
{#setvalue-6}
setValue
void setValue(double value)
Defined in src/symple/include/icy/symple/form.h:261
Replaces all current values with a single double value.
Parameters
valueDouble value to set.
{#setvalue-7}
setValue
void setValue(bool value)
Defined in src/symple/include/icy/symple/form.h:265
Replaces all current values with a single boolean value.
Parameters
valueBoolean value to set.
{#addvalue}
addValue
void addValue(std::string_view value)
Defined in src/symple/include/icy/symple/form.h:269
Appends a string value to the values array.
Parameters
valueString value to append.
{#addvalue-1}
addValue
void addValue(int value)
Defined in src/symple/include/icy/symple/form.h:273
Appends an integer value to the values array.
Parameters
valueInteger value to append.
{#addvalue-2}
addValue
void addValue(double value)
Defined in src/symple/include/icy/symple/form.h:277
Appends a double value to the values array.
Parameters
valueDouble value to append.
{#addvalue-3}
addValue
void addValue(bool value)
Defined in src/symple/include/icy/symple/form.h:281
Appends a boolean value to the values array.
Parameters
valueBoolean value to append.
{#values}
values
json::Value & values()
Defined in src/symple/include/icy/symple/form.h:284
Returns a reference to the JSON array of all values.
{#value-4}
value
const nodiscard
[[nodiscard]] std::string value() const
Defined in src/symple/include/icy/symple/form.h:288
Returns the first value as a string. Most field types (except multi-value) only use a single value.
{#intvalue}
intValue
const nodiscard
[[nodiscard]] int intValue() const
Defined in src/symple/include/icy/symple/form.h:291
Returns the first value parsed as an integer.
{#doublevalue}
doubleValue
const nodiscard
[[nodiscard]] double doubleValue() const
Defined in src/symple/include/icy/symple/form.h:294
Returns the first value parsed as a double.
{#boolvalue}
boolValue
const nodiscard
[[nodiscard]] bool boolValue() const
Defined in src/symple/include/icy/symple/form.h:298
Returns the first value parsed as a boolean. Treats "1", "true", and "on" as true; all other strings as false.
{#message-10}
Message
#include <icy/symple/message.h>
class Message
Defined in src/symple/include/icy/symple/message.h:27
Inherits:
Value,IPacketSubclassed by:Command,Event,Presence
Base Symple protocol message with addressing, status, data, and notes.
List of all members
| Name | Kind | Owner |
|---|---|---|
Message | function | Declared here |
Message | function | Declared here |
Message | function | Declared here |
clone | function | Declared here |
valid | function | Declared here |
clear | function | Declared here |
clearData | function | Declared here |
clearNotes | function | Declared here |
type | function | Declared here |
id | function | Declared here |
to | function | Declared here |
from | function | Declared here |
toUser | function | Declared here |
toId | function | Declared here |
fromUser | function | Declared here |
fromId | function | Declared here |
status | function | Declared here |
setType | function | Declared here |
setTo | function | Declared here |
setTo | function | Declared here |
setTo | function | Declared here |
setFrom | function | Declared here |
setFrom | function | Declared here |
setFrom | function | Declared here |
setStatus | function | Declared here |
notes | function | Declared here |
setNote | function | Declared here |
addNote | function | Declared here |
data | function | Declared here |
data | function | Declared here |
setData | function | Declared here |
setData | function | Declared here |
setData | function | Declared here |
setData | function | Declared here |
setData | function | Declared here |
removeData | function | Declared here |
hasData | function | Declared here |
read | function | Declared here |
read | function | Declared here |
write | function | Declared here |
isRequest | function | Declared here |
size | function | Declared here |
print | function | Declared here |
className | function | Declared here |
data | function | Declared here |
hasData | function | Declared here |
opaque | variable | Inherited from IPacket |
info | variable | Inherited from IPacket |
flags | variable | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
operator= | function | Inherited from IPacket |
clone | function | Inherited from IPacket |
~IPacket | function | Inherited from IPacket |
read | function | Inherited from IPacket |
write | function | Inherited from IPacket |
size | function | Inherited from IPacket |
hasData | function | Inherited from IPacket |
data | function | Inherited from IPacket |
constData | function | Inherited from IPacket |
className | function | Inherited from IPacket |
print | function | Inherited from IPacket |
operator<< | friend | Inherited from IPacket |
Inherited from IPacket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime. |
variable | info | Optional extra information about the packet. |
variable | flags | Provides basic information about the packet. |
function | IPacket inline | |
function | IPacket inline | Copy constructor; clones the info object if present. |
function | operator= inline | Copy assignment; clones the info object if present. |
function | clone virtual const | Returns a heap-allocated deep copy of this packet. |
function | ~IPacket virtual | Defaulted destructor. |
function | read virtual | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
function | write virtual const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
function | size virtual const inline | The size of the packet in bytes. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | constData virtual const inline | The const packet data pointer for buffered packets. |
function | className virtual const | Returns the class name of this packet type for logging and diagnostics. |
function | print virtual const inline | Prints a human-readable representation to the given stream. |
friend | operator<< inline | Stream insertion operator; delegates to print(). |
Public Methods
| Return | Name | Description |
|---|---|---|
Message | Constructs a new message with a random ID and type set to "message". | |
Message | Constructs a message from a JSON value; sets missing id/type fields. | |
Message | Copy constructor; preserves or generates id/type fields. | |
std::unique_ptr< IPacket > | clone virtual const override | Returns a heap-allocated copy of this message. |
bool | valid virtual const | Returns true if the message has both [type](#type-22) and [id](#id-7) fields. |
void | clear virtual | Clears all JSON fields from this message. |
void | clearData virtual | Clears the [data](#data-4) sub-object. |
void | clearNotes virtual | Clears the [notes](#notes) array. |
std::string | type const nodiscard | Returns the message type string (defaults to "message"). |
std::string | id const nodiscard | Returns the message ID string. |
Address | to const nodiscard | Returns the recipient address parsed from the [to](#to) field. |
Address | from const nodiscard | Returns the sender address parsed from the [from](#from) field. |
std::string | toUser const nodiscard | Returns the user component of the [to](#to) address without constructing an Address. |
std::string | toId const nodiscard | Returns the id component of the [to](#to) address without constructing an Address. |
std::string | fromUser const nodiscard | Returns the user component of the [from](#from) address without constructing an Address. |
std::string | fromId const nodiscard | Returns the id component of the [from](#from) address without constructing an Address. |
int | status const nodiscard | Returns the HTTP status code, or -1 if not set. |
void | setType | Sets the message type field. |
void | setTo | Sets the [to](#to) field from a peer's address. |
void | setTo | Sets the [to](#to) field from an address object. |
void | setTo | Sets the [to](#to) field from an address string. |
void | setFrom | Sets the [from](#from) field from a peer's address. |
void | setFrom | Sets the [from](#from) field from an address object. |
void | setFrom | Sets the [from](#from) field from an address string. |
void | setStatus | HTTP status codes are used to describe the message response. Throws std::invalid_argument if code is outside [101, 504]. |
json::Value & | notes | Returns a reference to the [notes](#notes) JSON array. |
void | setNote | Replaces all notes with a single note. |
void | addNote | Appends a note to the [notes](#notes) array. |
json::Value | data const | Returns a copy of the named data field. |
json::Value & | data | Returns a reference to the named data field (creates it if absent). |
json::Value & | setData | Creates or replaces a named data field; returns a reference to it. |
void | setData | Sets a named data field to a C-string value. |
void | setData | Sets a named data field to a string value. |
void | setData | Sets a named data field to a JSON value. |
void | setData | Sets a named data field to an integer value. |
void | removeData | Removes a named field from the [data](#data-4) sub-object. |
bool | hasData | Returns true if the named field exists in the [data](#data-4) sub-object. |
ssize_t | read virtual override | Deserialises the message from a raw buffer. |
ssize_t | read virtual | Deserialises the message from a JSON string. |
void | write virtual const override | Serialises the message as JSON into a buffer. |
bool | isRequest const nodiscard | Returns true if no status code has been set (i.e. status() == -1). |
size_t | size virtual const override | Returns the serialised JSON size in bytes. |
void | print virtual const override | Pretty-prints the message JSON to the given stream. |
const char * | className virtual const inline override | Returns the class name of this packet type for logging and diagnostics. |
char * | data virtual const inline | The packet data pointer for buffered packets. |
bool | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
{#message-11}
Message
Message()
Defined in src/symple/include/icy/symple/message.h:35
Constructs a new message with a random ID and type set to "message".
{#message-12}
Message
Message(const json::Value & root)
Defined in src/symple/include/icy/symple/message.h:39
Constructs a message from a JSON value; sets missing id/type fields.
Parameters
rootJSON object to initialise from.
{#message-13}
Message
Message(const Message & root)
Defined in src/symple/include/icy/symple/message.h:43
Copy constructor; preserves or generates id/type fields.
Parameters
rootSource message.
{#clone-18}
clone
virtual const override
virtual std::unique_ptr< IPacket > clone() const override
Defined in src/symple/include/icy/symple/message.h:49
Returns a heap-allocated copy of this message.
Reimplements
{#valid-15}
valid
virtual const
virtual bool valid() const
Defined in src/symple/include/icy/symple/message.h:52
Returns true if the message has both [type](#type-22) and [id](#id-7) fields.
Reimplemented by
{#clear-4}
clear
virtual
virtual void clear()
Defined in src/symple/include/icy/symple/message.h:55
Clears all JSON fields from this message.
{#cleardata}
clearData
virtual
virtual void clearData()
Defined in src/symple/include/icy/symple/message.h:58
Clears the [data](#data-4) sub-object.
{#clearnotes}
clearNotes
virtual
virtual void clearNotes()
Defined in src/symple/include/icy/symple/message.h:61
Clears the [notes](#notes) array.
{#type-22}
type
const nodiscard
[[nodiscard]] std::string type() const
Defined in src/symple/include/icy/symple/message.h:64
Returns the message type string (defaults to "message").
{#id-7}
id
const nodiscard
[[nodiscard]] std::string id() const
Defined in src/symple/include/icy/symple/message.h:67
Returns the message ID string.
{#to}
to
const nodiscard
[[nodiscard]] Address to() const
Defined in src/symple/include/icy/symple/message.h:70
Returns the recipient address parsed from the [to](#to) field.
{#from}
from
const nodiscard
[[nodiscard]] Address from() const
Defined in src/symple/include/icy/symple/message.h:73
Returns the sender address parsed from the [from](#from) field.
{#touser}
toUser
const nodiscard
[[nodiscard]] std::string toUser() const
Defined in src/symple/include/icy/symple/message.h:76
Returns the user component of the [to](#to) address without constructing an Address.
{#toid}
toId
const nodiscard
[[nodiscard]] std::string toId() const
Defined in src/symple/include/icy/symple/message.h:79
Returns the id component of the [to](#to) address without constructing an Address.
{#fromuser}
fromUser
const nodiscard
[[nodiscard]] std::string fromUser() const
Defined in src/symple/include/icy/symple/message.h:82
Returns the user component of the [from](#from) address without constructing an Address.
{#fromid}
fromId
const nodiscard
[[nodiscard]] std::string fromId() const
Defined in src/symple/include/icy/symple/message.h:85
Returns the id component of the [from](#from) address without constructing an Address.
{#status-3}
status
const nodiscard
[[nodiscard]] int status() const
Defined in src/symple/include/icy/symple/message.h:88
Returns the HTTP status code, or -1 if not set.
{#settype-2}
setType
void setType(std::string_view type)
Defined in src/symple/include/icy/symple/message.h:92
Sets the message type field.
Parameters
typeType string (e.g. "message", "command").
{#setto}
setTo
void setTo(const Peer & to)
Defined in src/symple/include/icy/symple/message.h:96
Sets the [to](#to) field from a peer's address.
Parameters
toDestination peer.
{#setto-1}
setTo
void setTo(const Address & to)
Defined in src/symple/include/icy/symple/message.h:100
Sets the [to](#to) field from an address object.
Parameters
toDestination address.
{#setto-2}
setTo
void setTo(std::string_view to)
Defined in src/symple/include/icy/symple/message.h:104
Sets the [to](#to) field from an address string.
Parameters
toDestination address string.
{#setfrom}
setFrom
void setFrom(const Peer & from)
Defined in src/symple/include/icy/symple/message.h:108
Sets the [from](#from) field from a peer's address.
Parameters
fromSender peer.
{#setfrom-1}
setFrom
void setFrom(const Address & from)
Defined in src/symple/include/icy/symple/message.h:112
Sets the [from](#from) field from an address object.
Parameters
fromSender address.
{#setfrom-2}
setFrom
void setFrom(std::string_view from)
Defined in src/symple/include/icy/symple/message.h:116
Sets the [from](#from) field from an address string.
Parameters
fromSender address string.
{#setstatus-1}
setStatus
void setStatus(int code)
Defined in src/symple/include/icy/symple/message.h:122
HTTP status codes are used to describe the message response. Throws std::invalid_argument if code is outside [101, 504].
Parameters
codeHTTP status code.
See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
{#notes}
notes
json::Value & notes()
Defined in src/symple/include/icy/symple/message.h:125
Returns a reference to the [notes](#notes) JSON array.
{#setnote}
setNote
void setNote(std::string_view type, std::string_view text)
Defined in src/symple/include/icy/symple/message.h:130
Replaces all notes with a single note.
Parameters
-
typeNote severity:[info](base.md#classicy_1_1IPacket_1ac2231c52e60bf60b402bc95cc9d6607d),warn, orerror. -
textNote message text.
{#addnote}
addNote
void addNote(std::string_view type, std::string_view text)
Defined in src/symple/include/icy/symple/message.h:135
Appends a note to the [notes](#notes) array.
Parameters
-
typeNote severity:[info](base.md#classicy_1_1IPacket_1ac2231c52e60bf60b402bc95cc9d6607d),warn, orerror. -
textNote message text.
{#data-4}
data
const
json::Value data(std::string_view name) const
Defined in src/symple/include/icy/symple/message.h:139
Returns a copy of the named data field.
Parameters
nameField name within[data](#data-4).
{#data-5}
data
json::Value & data(std::string_view name)
Defined in src/symple/include/icy/symple/message.h:143
Returns a reference to the named data field (creates it if absent).
Parameters
nameField name within[data](#data-4).
{#setdata}
setData
json::Value & setData(std::string_view name)
Defined in src/symple/include/icy/symple/message.h:147
Creates or replaces a named data field; returns a reference to it.
Parameters
nameField name within[data](#data-4).
{#setdata-1}
setData
void setData(std::string_view name, const char * data)
Defined in src/symple/include/icy/symple/message.h:152
Sets a named data field to a C-string value.
Parameters
-
nameField name within[data](#data-4). -
dataString value to assign.
{#setdata-2}
setData
void setData(std::string_view name, std::string_view data)
Defined in src/symple/include/icy/symple/message.h:157
Sets a named data field to a string value.
Parameters
-
nameField name within[data](#data-4). -
dataString value to assign.
{#setdata-3}
setData
void setData(std::string_view name, const json::Value & data)
Defined in src/symple/include/icy/symple/message.h:162
Sets a named data field to a JSON value.
Parameters
-
nameField name within[data](#data-4). -
dataJSON value to assign.
{#setdata-4}
setData
void setData(std::string_view name, int data)
Defined in src/symple/include/icy/symple/message.h:167
Sets a named data field to an integer value.
Parameters
-
nameField name within[data](#data-4). -
dataInteger value to assign.
{#removedata}
removeData
void removeData(std::string_view name)
Defined in src/symple/include/icy/symple/message.h:171
Removes a named field from the [data](#data-4) sub-object.
Parameters
nameField name to remove.
{#hasdata}
hasData
bool hasData(std::string_view name)
Defined in src/symple/include/icy/symple/message.h:175
Returns true if the named field exists in the [data](#data-4) sub-object.
Parameters
nameField name to look up.
{#read-13}
read
virtual override
virtual ssize_t read(const ConstBuffer & buf) override
Defined in src/symple/include/icy/symple/message.h:180
Deserialises the message from a raw buffer.
Parameters
bufBuffer containing the JSON payload.
Returns
Number of bytes consumed.
Reimplements
{#read-14}
read
virtual
virtual ssize_t read(const std::string & root)
Defined in src/symple/include/icy/symple/message.h:185
Deserialises the message from a JSON string.
Parameters
rootJSON string to parse.
Returns
Number of characters consumed.
{#write-28}
write
virtual const override
virtual void write(Buffer & buf) const override
Defined in src/symple/include/icy/symple/message.h:189
Serialises the message as JSON into a buffer.
Parameters
bufBuffer to append to.
Reimplements
{#isrequest}
isRequest
const nodiscard
[[nodiscard]] bool isRequest() const
Defined in src/symple/include/icy/symple/message.h:192
Returns true if no status code has been set (i.e. status() == -1).
{#size-12}
size
virtual const override
virtual size_t size() const override
Defined in src/symple/include/icy/symple/message.h:195
Returns the serialised JSON size in bytes.
Reimplements
{#print-16}
virtual const override
virtual void print(std::ostream & os) const override
Defined in src/symple/include/icy/symple/message.h:199
Pretty-prints the message JSON to the given stream.
Parameters
osOutput stream.
Reimplements
{#classname-8}
className
virtual const inline override
virtual inline const char * className() const override
Defined in src/symple/include/icy/symple/message.h:201
Returns the class name of this packet type for logging and diagnostics.
Reimplements
{#data-6}
data
virtual const inline
virtual inline char * data() const
Defined in src/symple/include/icy/symple/message.h:31
The packet data pointer for buffered packets.
Reimplements
{#hasdata-1}
hasData
virtual const inline
virtual inline bool hasData() const
Defined in src/symple/include/icy/symple/message.h:32
Returns true if the packet has a non-null data pointer.
Reimplements
{#peer-1}
Peer
#include <icy/symple/peer.h>
class Peer
Defined in src/symple/include/icy/symple/peer.h:30
Inherits:
Value
Symple peer record containing identity, presence, and custom fields.
A Peer object may also contain arbitrary application data set by the client to share with other peers on the network. See also: Address for further methods and basic accessors.
List of all members
| Name | Kind | Owner |
|---|---|---|
operator<< | friend | Declared here |
Peer | function | Declared here |
Peer | function | Declared here |
operator= | function | Declared here |
Peer | function | Declared here |
address | function | Declared here |
id | function | Declared here |
user | function | Declared here |
name | function | Declared here |
type | function | Declared here |
host | function | Declared here |
setID | function | Declared here |
setUser | function | Declared here |
setName | function | Declared here |
setType | function | Declared here |
setHost | function | Declared here |
valid | function | Declared here |
print | function | Declared here |
className | function | Declared here |
Friends
| Name | Description |
|---|---|
operator<< inline |
{#operator-38}
operator<<
inline
friend inline std::ostream & operator<<(std::ostream & os, const Peer & peer)
Defined in src/symple/include/icy/symple/peer.h:101
Public Methods
| Return | Name | Description |
|---|---|---|
Peer | Constructs an empty peer with type set to "Peer". | |
Peer | Copy constructor; preserves type field. | |
Peer & | operator= | Copy-assigns peer data from another peer. |
Peer | Constructs a peer from a raw JSON value. | |
Address | address const nodiscard | Returns the peer's address (user + session ID). |
std::string | id const nodiscard | Returns the session ID assigned by the server. |
std::string | user const nodiscard | Returns the user identifier. |
std::string | name const nodiscard | Returns the display name. |
std::string | type const nodiscard | Returns the peer type string (e.g. "Peer", "bot"). |
std::string | host const nodiscard | Returns the host address associated with this peer. |
void | setID | Sets the session ID field. |
void | setUser | Sets the user identifier field. |
void | setName | Sets the display name field. |
void | setType | Sets the peer type field. |
void | setHost | Sets the host address field. |
bool | valid virtual | Updates the peer from the given data object. |
void | print const | Writes the peer's JSON representation to the given stream. |
const char * | className virtual const inline |
{#peer-2}
Peer
Peer()
Defined in src/symple/include/icy/symple/peer.h:34
Constructs an empty peer with type set to "Peer".
{#peer-3}
Peer
Peer(const Peer & r)
Defined in src/symple/include/icy/symple/peer.h:38
Copy constructor; preserves type field.
Parameters
rSource peer.
{#operator-39}
operator=
Peer & operator=(const Peer & r)
Defined in src/symple/include/icy/symple/peer.h:42
Copy-assigns peer data from another peer.
Parameters
rSource peer.
{#peer-4}
Peer
Peer(const json::Value & r)
Defined in src/symple/include/icy/symple/peer.h:46
Constructs a peer from a raw JSON value.
Parameters
rJSON object containing peer fields.
{#address-17}
address
const nodiscard
[[nodiscard]] Address address() const
Defined in src/symple/include/icy/symple/peer.h:52
Returns the peer's address (user + session ID).
Returns
Address constructed from the [user](#user-2) and [id](#id-8) fields.
{#id-8}
id
const nodiscard
[[nodiscard]] std::string id() const
Defined in src/symple/include/icy/symple/peer.h:55
Returns the session ID assigned by the server.
{#user-2}
user
const nodiscard
[[nodiscard]] std::string user() const
Defined in src/symple/include/icy/symple/peer.h:58
Returns the user identifier.
{#name-14}
name
const nodiscard
[[nodiscard]] std::string name() const
Defined in src/symple/include/icy/symple/peer.h:61
Returns the display name.
{#type-23}
type
const nodiscard
[[nodiscard]] std::string type() const
Defined in src/symple/include/icy/symple/peer.h:65
Returns the peer type string (e.g. "Peer", "bot").
{#host-3}
host
const nodiscard
[[nodiscard]] std::string host() const
Defined in src/symple/include/icy/symple/peer.h:68
Returns the host address associated with this peer.
{#setid-1}
setID
void setID(std::string_view id)
Defined in src/symple/include/icy/symple/peer.h:72
Sets the session ID field.
Parameters
idSession ID string.
{#setuser}
setUser
void setUser(std::string_view user)
Defined in src/symple/include/icy/symple/peer.h:76
Sets the user identifier field.
Parameters
userUser identifier string.
{#setname-3}
setName
void setName(std::string_view name)
Defined in src/symple/include/icy/symple/peer.h:80
Sets the display name field.
Parameters
nameDisplay name string.
{#settype-3}
setType
void setType(std::string_view type)
Defined in src/symple/include/icy/symple/peer.h:85
Sets the peer type field.
Parameters
typeType string.
{#sethost-2}
setHost
void setHost(std::string_view host)
Defined in src/symple/include/icy/symple/peer.h:89
Sets the host address field.
Parameters
hostHost address string.
{#valid-16}
valid
virtual
virtual bool valid()
Defined in src/symple/include/icy/symple/peer.h:95
Updates the peer from the given data object.
Returns true if the peer has [id](#id-8), [user](#user-2), and [type](#type-23) fields.
{#print-17}
const
void print(std::ostream & os) const
Defined in src/symple/include/icy/symple/peer.h:99
Writes the peer's JSON representation to the given stream.
Parameters
osOutput stream.
{#classname-9}
className
virtual const inline
virtual inline const char * className() const
Defined in src/symple/include/icy/symple/peer.h:107
{#presence}
Presence
#include <icy/symple/presence.h>
class Presence
Defined in src/symple/include/icy/symple/presence.h:27
Inherits:
Message
Symple presence message indicating a peer's online status.
Presence messages carry peer data in the [data](#data-4) field. When probe is true the recipient should respond with their own presence.
List of all members
| Name | Kind | Owner |
|---|---|---|
Presence | function | Declared here |
Presence | function | Declared here |
Presence | function | Declared here |
isProbe | function | Declared here |
setProbe | function | Declared here |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
Message | function | Inherited from Message |
clone | function | Inherited from Message |
valid | function | Inherited from Message |
clear | function | Inherited from Message |
clearData | function | Inherited from Message |
clearNotes | function | Inherited from Message |
type | function | Inherited from Message |
id | function | Inherited from Message |
to | function | Inherited from Message |
from | function | Inherited from Message |
toUser | function | Inherited from Message |
toId | function | Inherited from Message |
fromUser | function | Inherited from Message |
fromId | function | Inherited from Message |
status | function | Inherited from Message |
setType | function | Inherited from Message |
setTo | function | Inherited from Message |
setTo | function | Inherited from Message |
setTo | function | Inherited from Message |
setFrom | function | Inherited from Message |
setFrom | function | Inherited from Message |
setFrom | function | Inherited from Message |
setStatus | function | Inherited from Message |
notes | function | Inherited from Message |
setNote | function | Inherited from Message |
addNote | function | Inherited from Message |
data | function | Inherited from Message |
data | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
setData | function | Inherited from Message |
removeData | function | Inherited from Message |
hasData | function | Inherited from Message |
read | function | Inherited from Message |
read | function | Inherited from Message |
write | function | Inherited from Message |
isRequest | function | Inherited from Message |
size | function | Inherited from Message |
print | function | Inherited from Message |
className | function | Inherited from Message |
data | function | Inherited from Message |
hasData | function | Inherited from Message |
opaque | variable | Inherited from IPacket |
info | variable | Inherited from IPacket |
flags | variable | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
operator= | function | Inherited from IPacket |
clone | function | Inherited from IPacket |
~IPacket | function | Inherited from IPacket |
read | function | Inherited from IPacket |
write | function | Inherited from IPacket |
size | function | Inherited from IPacket |
hasData | function | Inherited from IPacket |
data | function | Inherited from IPacket |
constData | function | Inherited from IPacket |
className | function | Inherited from IPacket |
print | function | Inherited from IPacket |
operator<< | friend | Inherited from IPacket |
Inherited from Message
| Kind | Name | Description |
|---|---|---|
function | Message | Constructs a new message with a random ID and type set to "message". |
function | Message | Constructs a message from a JSON value; sets missing id/type fields. |
function | Message | Copy constructor; preserves or generates id/type fields. |
function | clone virtual const override | Returns a heap-allocated copy of this message. |
function | valid virtual const | Returns true if the message has both [type](#type-22) and [id](#id-7) fields. |
function | clear virtual | Clears all JSON fields from this message. |
function | clearData virtual | Clears the [data](#data-4) sub-object. |
function | clearNotes virtual | Clears the [notes](#notes) array. |
function | type const nodiscard | Returns the message type string (defaults to "message"). |
function | id const nodiscard | Returns the message ID string. |
function | to const nodiscard | Returns the recipient address parsed from the [to](#to) field. |
function | from const nodiscard | Returns the sender address parsed from the [from](#from) field. |
function | toUser const nodiscard | Returns the user component of the [to](#to) address without constructing an Address. |
function | toId const nodiscard | Returns the id component of the [to](#to) address without constructing an Address. |
function | fromUser const nodiscard | Returns the user component of the [from](#from) address without constructing an Address. |
function | fromId const nodiscard | Returns the id component of the [from](#from) address without constructing an Address. |
function | status const nodiscard | Returns the HTTP status code, or -1 if not set. |
function | setType | Sets the message type field. |
function | setTo | Sets the [to](#to) field from a peer's address. |
function | setTo | Sets the [to](#to) field from an address object. |
function | setTo | Sets the [to](#to) field from an address string. |
function | setFrom | Sets the [from](#from) field from a peer's address. |
function | setFrom | Sets the [from](#from) field from an address object. |
function | setFrom | Sets the [from](#from) field from an address string. |
function | setStatus | HTTP status codes are used to describe the message response. Throws std::invalid_argument if code is outside [101, 504]. |
function | notes | Returns a reference to the [notes](#notes) JSON array. |
function | setNote | Replaces all notes with a single note. |
function | addNote | Appends a note to the [notes](#notes) array. |
function | data const | Returns a copy of the named data field. |
function | data | Returns a reference to the named data field (creates it if absent). |
function | setData | Creates or replaces a named data field; returns a reference to it. |
function | setData | Sets a named data field to a C-string value. |
function | setData | Sets a named data field to a string value. |
function | setData | Sets a named data field to a JSON value. |
function | setData | Sets a named data field to an integer value. |
function | removeData | Removes a named field from the [data](#data-4) sub-object. |
function | hasData | Returns true if the named field exists in the [data](#data-4) sub-object. |
function | read virtual override | Deserialises the message from a raw buffer. |
function | read virtual | Deserialises the message from a JSON string. |
function | write virtual const override | Serialises the message as JSON into a buffer. |
function | isRequest const nodiscard | Returns true if no status code has been set (i.e. status() == -1). |
function | size virtual const override | Returns the serialised JSON size in bytes. |
function | print virtual const override | Pretty-prints the message JSON to the given stream. |
function | className virtual const inline override | Returns the class name of this packet type for logging and diagnostics. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
Inherited from IPacket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime. |
variable | info | Optional extra information about the packet. |
variable | flags | Provides basic information about the packet. |
function | IPacket inline | |
function | IPacket inline | Copy constructor; clones the info object if present. |
function | operator= inline | Copy assignment; clones the info object if present. |
function | clone virtual const | Returns a heap-allocated deep copy of this packet. |
function | ~IPacket virtual | Defaulted destructor. |
function | read virtual | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
function | write virtual const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
function | size virtual const inline | The size of the packet in bytes. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | constData virtual const inline | The const packet data pointer for buffered packets. |
function | className virtual const | Returns the class name of this packet type for logging and diagnostics. |
function | print virtual const inline | Prints a human-readable representation to the given stream. |
friend | operator<< inline | Stream insertion operator; delegates to print(). |
Public Methods
| Return | Name | Description |
|---|---|---|
Presence | Constructs a presence message with type set to "presence". | |
Presence | Constructs a presence message from a JSON value. | |
Presence | Copy constructor. | |
bool | isProbe | Returns true if this is a presence probe request. Recipients of a probe should send back their own presence. |
void | setProbe | Sets or clears the probe flag on this presence message. |
{#presence-1}
Presence
Presence()
Defined in src/symple/include/icy/symple/presence.h:31
Constructs a presence message with type set to "presence".
{#presence-2}
Presence
Presence(const json::Value & root)
Defined in src/symple/include/icy/symple/presence.h:35
Constructs a presence message from a JSON value.
Parameters
rootJSON object to initialise from.
{#presence-3}
Presence
Presence(const Presence & root)
Defined in src/symple/include/icy/symple/presence.h:39
Copy constructor.
Parameters
rootSource presence message.
{#isprobe}
isProbe
bool isProbe()
Defined in src/symple/include/icy/symple/presence.h:45
Returns true if this is a presence probe request. Recipients of a probe should send back their own presence.
{#setprobe}
setProbe
void setProbe(bool flag)
Defined in src/symple/include/icy/symple/presence.h:49
Sets or clears the probe flag on this presence message.
Parameters
flagTrue to mark this as a probe.
{#roster-2}
Roster
#include <icy/symple/roster.h>
class Roster
Defined in src/symple/include/icy/symple/roster.h:29
Inherits:
string, Peer >
The Roster provides a registry for active network peers indexed by session ID.
List of all members
| Name | Kind | Owner |
|---|---|---|
PeerAdded | variable | Declared here |
PeerRemoved | variable | Declared here |
Roster | function | Declared here |
getByHost | function | Declared here |
peers | function | Declared here |
print | function | Declared here |
className | function | Declared here |
onAdd | function | Declared here |
onRemove | function | Declared here |
Map | typedef | Inherited from KeyedStore |
_map | variable | Inherited from KeyedStore |
KeyedStore | function | Inherited from KeyedStore |
~KeyedStore | function | Inherited from KeyedStore |
KeyedStore | function | Inherited from KeyedStore |
operator= | function | Inherited from KeyedStore |
KeyedStore | function | Inherited from KeyedStore |
operator= | function | Inherited from KeyedStore |
get | function | Inherited from KeyedStore |
add | function | Inherited from KeyedStore |
tryAdd | function | Inherited from KeyedStore |
put | function | Inherited from KeyedStore |
erase | function | Inherited from KeyedStore |
contains | function | Inherited from KeyedStore |
empty | function | Inherited from KeyedStore |
size | function | Inherited from KeyedStore |
clear | function | Inherited from KeyedStore |
map | function | Inherited from KeyedStore |
map | function | Inherited from KeyedStore |
begin | function | Inherited from KeyedStore |
end | function | Inherited from KeyedStore |
begin | function | Inherited from KeyedStore |
end | function | Inherited from KeyedStore |
onAdd | function | Inherited from KeyedStore |
onRemove | function | Inherited from KeyedStore |
Inherited from KeyedStore
| Kind | Name | Description |
|---|---|---|
typedef | Map | |
variable | _map | |
function | KeyedStore | Defaulted constructor. |
function | ~KeyedStore virtual inline | |
function | KeyedStore | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | KeyedStore | Defaulted constructor. |
function | operator= | Defaulted assignment operator. |
function | get const inline | Returns the item for key, or nullptr if not found. |
function | add inline | Inserts a uniquely owned item. Returns a reference to the stored item. |
function | tryAdd inline | Inserts if absent; returns false on duplicate (never throws). |
function | put inline | Inserts or replaces the item under key. |
function | erase inline | Removes and destroys the item under key. |
function | contains const inline | |
function | empty const inline | |
function | size const inline | |
function | clear inline | |
function | map inline | Direct map access for iteration. |
function | map const inline | |
function | begin inline | |
function | end inline | |
function | begin const inline | |
function | end const inline | |
function | onAdd virtual inline | Override for lifecycle reactions. |
function | onRemove virtual inline |
Public Attributes
| Return | Name | Description |
|---|---|---|
Signal< void(Peer &)> | PeerAdded | Lifecycle signals for external observers (samples, UI). |
Signal< void(const Peer &)> | PeerRemoved |
{#peeradded}
PeerAdded
Signal< void(Peer &)> PeerAdded
Defined in src/symple/include/icy/symple/roster.h:46
Lifecycle signals for external observers (samples, UI).
{#peerremoved}
PeerRemoved
Signal< void(const Peer &)> PeerRemoved
Defined in src/symple/include/icy/symple/roster.h:47
Public Methods
| Return | Name | Description |
|---|---|---|
Roster | ||
Peer * | getByHost | Returns the first peer which matches the given host address. |
Map | peers const nodiscard | Returns a deep copy of the peer map. |
void | print const | |
const char * | className virtual const inline |
{#roster-3}
Roster
Roster()
Defined in src/symple/include/icy/symple/roster.h:32
{#getbyhost}
getByHost
Peer * getByHost(std::string_view host)
Defined in src/symple/include/icy/symple/roster.h:36
Returns the first peer which matches the given host address.
{#peers}
peers
const nodiscard
[[nodiscard]] Map peers() const
Defined in src/symple/include/icy/symple/roster.h:39
Returns a deep copy of the peer map.
{#print-18}
const
void print(std::ostream & os) const
Defined in src/symple/include/icy/symple/roster.h:41
{#classname-10}
className
virtual const inline
virtual inline const char * className() const
Defined in src/symple/include/icy/symple/roster.h:43
Protected Methods
| Return | Name | Description |
|---|---|---|
void | onAdd inline override | |
void | onRemove inline override |
{#onadd}
onAdd
inline override
inline void onAdd(const std::string &, Peer * peer) override
Defined in src/symple/include/icy/symple/roster.h:50
{#onremove}
onRemove
inline override
inline void onRemove(const std::string &, Peer * peer) override
Defined in src/symple/include/icy/symple/roster.h:51
{#server-10}
Server
#include <icy/symple/server.h>
class Server
Defined in src/symple/include/icy/symple/server.h:136
Symple v4 server.
Accepts WebSocket connections, authenticates peers, manages rooms, and routes messages. Implements the Symple v4 protocol over native WebSocket.
Usage: smpl::Server server; server.start({.port = 4500});
// Optional: custom authentication server.Authenticate += [](ServerPeer& peer, const json::Value& auth, bool& allowed, std::vectorstd::string& rooms) { allowed = (auth.value("token", "") == "secret"); rooms.push_back("team-a"); };
The server also serves as an HTTP server, so you can serve static files (e.g. a web UI) on the same port.
List of all members
| Name | Kind | Owner |
|---|---|---|
Factory | friend | Declared here |
Authenticate | variable | Declared here |
PeerConnected | variable | Declared here |
PeerDisconnected | variable | Declared here |
Server | function | Declared here |
Server | function | Declared here |
start | function | Declared here |
start | function | Declared here |
stop | function | Declared here |
broadcast | function | Declared here |
broadcastRooms | function | Declared here |
sendTo | function | Declared here |
sendToUser | function | Declared here |
getPeer | function | Declared here |
getPeersInRoom | function | Declared here |
peerCount | function | Declared here |
addVirtualPeer | function | Declared here |
removeVirtualPeer | function | Declared here |
httpServer | function | Declared here |
loop | function | Declared here |
_opts | variable | Declared here |
_loop | variable | Declared here |
_http | variable | Declared here |
_peerRegistry | variable | Declared here |
_roomIndex | variable | Declared here |
_mutex | variable | Declared here |
_shuttingDown | variable | Declared here |
_httpFallback | variable | Declared here |
onAuth | function | Declared here |
onMessage | function | Declared here |
onJoin | function | Declared here |
onLeave | function | Declared here |
onDisconnect | function | Declared here |
route | function | Declared here |
deliver | function | Declared here |
deliverSerialized | function | Declared here |
sendPresenceSnapshot | function | Declared here |
Friends
| Name | Description |
|---|---|
Factory |
{#factory-2}
Factory
friend class Factory
Defined in src/symple/include/icy/symple/server.h:279
Public Attributes
| Return | Name | Description |
|---|---|---|
Signal< void(ServerPeer &, const json::Value &auth, bool &allowed, std::vector< std::string > &rooms)> | Authenticate | Custom authentication hook. Set allowed to false to reject the peer. Append to rooms to assign team/group memberships. If not connected, all peers with a valid user field are accepted. |
Signal< void(ServerPeer &)> | PeerConnected | Peer authenticated and online. |
Signal< void(ServerPeer &)> | PeerDisconnected | Peer disconnected. |
{#authenticate-2}
Authenticate
Signal< void(ServerPeer &, const json::Value &auth, bool &allowed, std::vector< std::string > &rooms)> Authenticate
Defined in src/symple/include/icy/symple/server.h:213
Custom authentication hook. Set allowed to false to reject the peer. Append to rooms to assign team/group memberships. If not connected, all peers with a valid user field are accepted.
{#peerconnected-1}
PeerConnected
Signal< void(ServerPeer &)> PeerConnected
Defined in src/symple/include/icy/symple/server.h:216
Peer authenticated and online.
{#peerdisconnected-1}
PeerDisconnected
Signal< void(ServerPeer &)> PeerDisconnected
Defined in src/symple/include/icy/symple/server.h:219
Peer disconnected.
Public Methods
| Return | Name | Description |
|---|---|---|
Server | Constructs a server using the given event loop. | |
Server | Deleted constructor. | |
void | start | Starts the server with the given options. Begins accepting WebSocket connections on opts.host:opts.port. |
void | start | Starts the server with a custom HTTP factory for non-WebSocket requests. The Symple server handles WebSocket upgrades internally; any other HTTP request (e.g. static files, REST API) is delegated to this factory. |
void | stop | Broadcasts a shutdown notice to all peers, closes the listen socket, and releases all internal state. Safe to call more than once. |
void | broadcast | Broadcast a message to all peers in a room (excluding sender). |
void | broadcastRooms | Broadcast to multiple rooms with per-recipient dedup. |
bool | sendTo | Send a message to a specific peer by session ID. |
bool | sendToUser | Send a message to any peer with the given user name. |
ServerPeer * | getPeer nodiscard | Get a connected peer by session ID. |
std::vector< ServerPeer * > | getPeersInRoom nodiscard | Get all peers in a room. |
size_t | peerCount const nodiscard | Number of connected, authenticated peers. |
void | addVirtualPeer | Register a virtual peer that receives messages via callback. |
void | removeVirtualPeer | Remove a virtual peer by session ID. |
http::Server & | httpServer inline nodiscard | Access the underlying HTTP server (e.g. to serve static files). |
uv::Loop * | loop const inline nodiscard | Event loop that owns the Symple server and all peer connections. |
{#server-11}
Server
Server(uv::Loop * loop = uv::defaultLoop())
Defined in src/symple/include/icy/symple/server.h:157
Constructs a server using the given event loop.
Parameters
looplibuv event loop; defaults to uv::defaultLoop().
{#server-12}
Server
Server(const Server &) = delete
Defined in src/symple/include/icy/symple/server.h:160
Deleted constructor.
{#start-17}
start
void start(const Options & opts)
Defined in src/symple/include/icy/symple/server.h:166
Starts the server with the given options. Begins accepting WebSocket connections on opts.host:opts.port.
Parameters
optsServer configuration options.
{#start-18}
start
void start(const Options & opts, std::unique_ptr< http::ServerConnectionFactory > httpFactory)
Defined in src/symple/include/icy/symple/server.h:173
Starts the server with a custom HTTP factory for non-WebSocket requests. The Symple server handles WebSocket upgrades internally; any other HTTP request (e.g. static files, REST API) is delegated to this factory.
Parameters
-
optsServer configuration options. -
httpFactoryFactory for HTTP responders; may be nullptr.
{#stop-14}
stop
void stop()
Defined in src/symple/include/icy/symple/server.h:178
Broadcasts a shutdown notice to all peers, closes the listen socket, and releases all internal state. Safe to call more than once.
{#broadcast}
broadcast
void broadcast(const std::string & room, const json::Value & msg, const std::string & excludeId = {})
Defined in src/symple/include/icy/symple/server.h:182
Broadcast a message to all peers in a room (excluding sender).
{#broadcastrooms}
broadcastRooms
void broadcastRooms(const std::unordered_set< std::string > & rooms, const json::Value & msg, const std::string & excludeId = {})
Defined in src/symple/include/icy/symple/server.h:186
Broadcast to multiple rooms with per-recipient dedup.
{#sendto}
sendTo
bool sendTo(const std::string & peerId, const json::Value & msg)
Defined in src/symple/include/icy/symple/server.h:191
Send a message to a specific peer by session ID.
{#sendtouser}
sendToUser
bool sendToUser(const std::string & user, const json::Value & msg)
Defined in src/symple/include/icy/symple/server.h:194
Send a message to any peer with the given user name.
{#getpeer}
getPeer
nodiscard
[[nodiscard]] ServerPeer * getPeer(const std::string & id)
Defined in src/symple/include/icy/symple/server.h:197
Get a connected peer by session ID.
{#getpeersinroom}
getPeersInRoom
nodiscard
[[nodiscard]] std::vector< ServerPeer * > getPeersInRoom(const std::string & room)
Defined in src/symple/include/icy/symple/server.h:200
Get all peers in a room.
{#peercount}
peerCount
const nodiscard
[[nodiscard]] size_t peerCount() const
Defined in src/symple/include/icy/symple/server.h:203
Number of connected, authenticated peers.
{#addvirtualpeer}
addVirtualPeer
void addVirtualPeer(const Peer & peer, const std::vector< std::string > & rooms, std::function< void(const json::Value &)> handler)
Defined in src/symple/include/icy/symple/server.h:230
Register a virtual peer that receives messages via callback.
The virtual peer appears in presence broadcasts and is routable like any WebSocket-connected peer. Messages addressed to it are delivered via the callback instead of a WebSocket connection.
Parameters
-
peerPeer data (must have "id", "user", "name" fields). -
roomsRooms the virtual peer joins. -
handlerCalled when a message is routed to this peer.
{#removevirtualpeer}
removeVirtualPeer
void removeVirtualPeer(const std::string & peerId)
Defined in src/symple/include/icy/symple/server.h:235
Remove a virtual peer by session ID.
{#httpserver}
httpServer
inline nodiscard
[[nodiscard]] inline http::Server & httpServer()
Defined in src/symple/include/icy/symple/server.h:238
Access the underlying HTTP server (e.g. to serve static files).
{#loop-9}
loop
const inline nodiscard
[[nodiscard]] inline uv::Loop * loop() const
Defined in src/symple/include/icy/symple/server.h:241
Event loop that owns the Symple server and all peer connections.
Private Attributes
| Return | Name | Description |
|---|---|---|
Options | _opts | |
uv::Loop * | _loop | |
std::unique_ptr< http::Server > | _http | |
std::unique_ptr< PeerRegistry > | _peerRegistry | |
std::unique_ptr< RoomIndex > | _roomIndex | |
std::mutex | _mutex | |
std::atomic< bool > | _shuttingDown | |
std::unique_ptr< http::ServerConnectionFactory > | _httpFallback | Fallback factory for non-WebSocket HTTP requests. |
{#_opts}
_opts
Options _opts
Defined in src/symple/include/icy/symple/server.h:267
{#_loop-3}
_loop
uv::Loop * _loop = nullptr
Defined in src/symple/include/icy/symple/server.h:268
{#_http}
_http
std::unique_ptr< http::Server > _http
Defined in src/symple/include/icy/symple/server.h:269
{#_peerregistry}
_peerRegistry
std::unique_ptr< PeerRegistry > _peerRegistry
Defined in src/symple/include/icy/symple/server.h:270
{#_roomindex}
_roomIndex
std::unique_ptr< RoomIndex > _roomIndex
Defined in src/symple/include/icy/symple/server.h:271
{#_mutex-16}
_mutex
std::mutex _mutex
Defined in src/symple/include/icy/symple/server.h:273
{#_shuttingdown}
_shuttingDown
std::atomic< bool > _shuttingDown {false}
Defined in src/symple/include/icy/symple/server.h:274
{#_httpfallback}
_httpFallback
std::unique_ptr< http::ServerConnectionFactory > _httpFallback
Defined in src/symple/include/icy/symple/server.h:277
Fallback factory for non-WebSocket HTTP requests.
Private Methods
| Return | Name | Description |
|---|---|---|
void | onAuth | |
void | onMessage | |
void | onJoin | |
void | onLeave | |
void | onDisconnect | |
void | route | |
bool | deliver | |
bool | deliverSerialized | |
void | sendPresenceSnapshot |
{#onauth}
onAuth
void onAuth(ServerPeer & peer, const json::Value & msg, std::unique_lock< std::mutex > & lock)
Defined in src/symple/include/icy/symple/server.h:252
{#onmessage}
onMessage
void onMessage(ServerPeer & peer, json::Value msg)
Defined in src/symple/include/icy/symple/server.h:253
{#onjoin}
onJoin
void onJoin(ServerPeer & peer, const std::string & room)
Defined in src/symple/include/icy/symple/server.h:254
{#onleave}
onLeave
void onLeave(ServerPeer & peer, const std::string & room)
Defined in src/symple/include/icy/symple/server.h:255
{#ondisconnect}
onDisconnect
void onDisconnect(ServerPeer & peer, std::unique_lock< std::mutex > & lock)
Defined in src/symple/include/icy/symple/server.h:256
{#route}
route
void route(ServerPeer & sender, const json::Value & msg)
Defined in src/symple/include/icy/symple/server.h:257
{#deliver}
deliver
bool deliver(const std::string & peerId, const json::Value & msg)
Defined in src/symple/include/icy/symple/server.h:258
{#deliverserialized}
deliverSerialized
bool deliverSerialized(const std::string & peerId, const char * data, size_t len, const json::Value & msg)
Defined in src/symple/include/icy/symple/server.h:259
{#sendpresencesnapshot}
sendPresenceSnapshot
void sendPresenceSnapshot(ServerPeer & recipient, const std::unordered_set< std::string > & rooms, std::string_view excludeId = {})
Defined in src/symple/include/icy/symple/server.h:263
{#peerregistry}
PeerRegistry
#include <src/symple/src/server/detail.h>
class PeerRegistry
Defined in src/symple/src/server/detail.h:27
List of all members
| Name | Kind | Owner |
|---|---|---|
add | function | Declared here |
addVirtual | function | Declared here |
bind | function | Declared here |
unbind | function | Declared here |
erase | function | Declared here |
eraseVirtual | function | Declared here |
clear | function | Declared here |
find | function | Declared here |
find | function | Declared here |
findVirtual | function | Declared here |
findVirtual | function | Declared here |
findByConnection | function | Declared here |
findByConnection | function | Declared here |
size | function | Declared here |
peers | function | Declared here |
_peers | variable | Declared here |
_virtualPeers | variable | Declared here |
_connToPeer | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
void | add | |
void | addVirtual | |
void | bind | |
void | unbind | |
void | erase | |
void | eraseVirtual | |
void | clear | |
ServerPeer * | find nodiscard | |
const ServerPeer * | find const nodiscard | |
VirtualPeer * | findVirtual nodiscard | |
const VirtualPeer * | findVirtual const nodiscard | |
ServerPeer * | findByConnection nodiscard | |
const ServerPeer * | findByConnection const nodiscard | |
size_t | size const nodiscard | |
const std::unordered_map< std::string, std::unique_ptr< ServerPeer > > & | peers const inline nodiscard |
{#add-3}
add
void add(std::string id, std::unique_ptr< ServerPeer > peer)
Defined in src/symple/src/server/detail.h:30
{#addvirtual}
addVirtual
void addVirtual(std::string id, VirtualPeer peer)
Defined in src/symple/src/server/detail.h:31
{#bind-4}
bind
void bind(http::ServerConnection & conn, const std::string & id)
Defined in src/symple/src/server/detail.h:32
{#unbind}
unbind
void unbind(http::ServerConnection & conn)
Defined in src/symple/src/server/detail.h:33
{#erase}
erase
void erase(const std::string & id)
Defined in src/symple/src/server/detail.h:34
{#erasevirtual}
eraseVirtual
void eraseVirtual(const std::string & id)
Defined in src/symple/src/server/detail.h:35
{#clear-5}
clear
void clear()
Defined in src/symple/src/server/detail.h:36
{#find}
find
nodiscard
[[nodiscard]] ServerPeer * find(const std::string & id)
Defined in src/symple/src/server/detail.h:38
{#find-1}
find
const nodiscard
[[nodiscard]] const ServerPeer * find(const std::string & id) const
Defined in src/symple/src/server/detail.h:39
{#findvirtual}
findVirtual
nodiscard
[[nodiscard]] VirtualPeer * findVirtual(const std::string & id)
Defined in src/symple/src/server/detail.h:40
{#findvirtual-1}
findVirtual
const nodiscard
[[nodiscard]] const VirtualPeer * findVirtual(const std::string & id) const
Defined in src/symple/src/server/detail.h:41
{#findbyconnection}
findByConnection
nodiscard
[[nodiscard]] ServerPeer * findByConnection(http::ServerConnection & conn)
Defined in src/symple/src/server/detail.h:42
{#findbyconnection-1}
findByConnection
const nodiscard
[[nodiscard]] const ServerPeer * findByConnection(http::ServerConnection & conn) const
Defined in src/symple/src/server/detail.h:43
{#size-13}
size
const nodiscard
[[nodiscard]] size_t size() const
Defined in src/symple/src/server/detail.h:44
{#peers-1}
peers
const inline nodiscard
[[nodiscard]] inline const std::unordered_map< std::string, std::unique_ptr< ServerPeer > > & peers() const
Defined in src/symple/src/server/detail.h:46
Private Attributes
| Return | Name | Description |
|---|---|---|
std::unordered_map< std::string, std::unique_ptr< ServerPeer > > | _peers | |
std::unordered_map< std::string, VirtualPeer > | _virtualPeers | |
std::unordered_map< http::ServerConnection *, std::string > | _connToPeer |
{#_peers}
_peers
std::unordered_map< std::string, std::unique_ptr< ServerPeer > > _peers
Defined in src/symple/src/server/detail.h:52
{#_virtualpeers}
_virtualPeers
std::unordered_map< std::string, VirtualPeer > _virtualPeers
Defined in src/symple/src/server/detail.h:53
{#_conntopeer}
_connToPeer
std::unordered_map< http::ServerConnection *, std::string > _connToPeer
Defined in src/symple/src/server/detail.h:54
{#roomindex}
RoomIndex
#include <src/symple/src/server/detail.h>
class RoomIndex
Defined in src/symple/src/server/detail.h:58
List of all members
| Name | Kind | Owner |
|---|---|---|
join | function | Declared here |
leave | function | Declared here |
leaveAll | function | Declared here |
clear | function | Declared here |
members | function | Declared here |
collectRecipients | function | Declared here |
MemberSet | typedef | Declared here |
_rooms | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
void | join | |
void | leave | |
void | leaveAll | |
void | clear | |
const MemberSet * | members const nodiscard | |
std::unordered_set< std::string > | collectRecipients const nodiscard |
{#join}
join
void join(const std::string & room, const std::string & peerId)
Defined in src/symple/src/server/detail.h:63
{#leave}
leave
void leave(const std::string & room, const std::string & peerId)
Defined in src/symple/src/server/detail.h:64
{#leaveall}
leaveAll
void leaveAll(const std::string & peerId)
Defined in src/symple/src/server/detail.h:65
{#clear-6}
clear
void clear()
Defined in src/symple/src/server/detail.h:66
{#members}
members
const nodiscard
[[nodiscard]] const MemberSet * members(const std::string & room) const
Defined in src/symple/src/server/detail.h:68
{#collectrecipients}
collectRecipients
const nodiscard
[[nodiscard]] std::unordered_set< std::string > collectRecipients(const std::unordered_set< std::string > & rooms, std::string_view excludeId = {}) const
Defined in src/symple/src/server/detail.h:69
Public Types
| Name | Description |
|---|---|
MemberSet |
{#memberset}
MemberSet
using MemberSet = std::unordered_set< std::string >
Defined in src/symple/src/server/detail.h:61
Private Attributes
| Return | Name | Description |
|---|---|---|
std::unordered_map< std::string, MemberSet > | _rooms |
{#_rooms}
_rooms
std::unordered_map< std::string, MemberSet > _rooms
Defined in src/symple/src/server/detail.h:74
{#options-16}
Options
#include <icy/symple/server.h>
struct Options
Defined in src/symple/include/icy/symple/server.h:140
Configuration options for the Symple server.
List of all members
| Name | Kind | Owner |
|---|---|---|
host | variable | Declared here |
port | variable | Declared here |
socket | variable | Declared here |
authentication | variable | Declared here |
dynamicRooms | variable | Declared here |
maxConnections | variable | Declared here |
maxMessageSize | variable | Declared here |
rateLimit | variable | Declared here |
rateSeconds | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | host | |
uint16_t | port | |
net::TCPSocket::Ptr | socket | Optional pre-created listen socket (e.g. SSLSocket for HTTPS/WSS). |
bool | authentication | Require token in auth message. |
bool | dynamicRooms | Allow clients to join/leave rooms. |
size_t | maxConnections | Max WebSocket connections (0 = unlimited). |
size_t | maxMessageSize | Max message payload in bytes (64KB default). |
double | rateLimit | Messages per rate window. |
double | rateSeconds | Rate window in seconds. |
{#host-4}
host
std::string host = "0.0.0.0"
Defined in src/symple/include/icy/symple/server.h:142
{#port-3}
port
uint16_t port = 4500
Defined in src/symple/include/icy/symple/server.h:143
{#socket-7}
socket
net::TCPSocket::Ptr socket
Defined in src/symple/include/icy/symple/server.h:144
Optional pre-created listen socket (e.g. SSLSocket for HTTPS/WSS).
{#authentication}
authentication
bool authentication = false
Defined in src/symple/include/icy/symple/server.h:145
Require token in auth message.
{#dynamicrooms}
dynamicRooms
bool dynamicRooms = true
Defined in src/symple/include/icy/symple/server.h:146
Allow clients to join/leave rooms.
{#maxconnections}
maxConnections
size_t maxConnections = 0
Defined in src/symple/include/icy/symple/server.h:149
Max WebSocket connections (0 = unlimited).
{#maxmessagesize}
maxMessageSize
size_t maxMessageSize = 64 * 1024
Defined in src/symple/include/icy/symple/server.h:150
Max message payload in bytes (64KB default).
{#ratelimit}
rateLimit
double rateLimit = 100.0
Defined in src/symple/include/icy/symple/server.h:151
Messages per rate window.
{#rateseconds}
rateSeconds
double rateSeconds = 10.0
Defined in src/symple/include/icy/symple/server.h:152
Rate window in seconds.
{#virtualpeer}
VirtualPeer
#include <src/symple/src/server/detail.h>
struct VirtualPeer
Defined in src/symple/src/server/detail.h:19
List of all members
| Name | Kind | Owner |
|---|---|---|
peer | variable | Declared here |
rooms | variable | Declared here |
handler | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
Peer | peer | |
std::unordered_set< std::string > | rooms | |
std::function< void(const json::Value &)> | handler |
{#peer-5}
peer
Peer peer
Defined in src/symple/src/server/detail.h:21
{#rooms-1}
rooms
std::unordered_set< std::string > rooms
Defined in src/symple/src/server/detail.h:22
{#handler}
handler
std::function< void(const json::Value &)> handler
Defined in src/symple/src/server/detail.h:23
{#routingpolicy}
RoutingPolicy
#include <src/symple/src/server/detail.h>
struct RoutingPolicy
Defined in src/symple/src/server/detail.h:78
List of all members
| Name | Kind | Owner |
|---|---|---|
sharesAnyRoom | function | Declared here |
canDirectMessage | function | Declared here |
canDirectMessage | function | Declared here |
canBroadcastToRoom | function | Declared here |
Public Static Methods
| Return | Name | Description |
|---|---|---|
bool | sharesAnyRoom static nodiscard | |
bool | canDirectMessage static nodiscard | |
bool | canDirectMessage static nodiscard | |
bool | canBroadcastToRoom static nodiscard |
{#sharesanyroom}
sharesAnyRoom
static nodiscard
[[nodiscard]] static bool sharesAnyRoom(const std::unordered_set< std::string > & a, const std::unordered_set< std::string > & b)
Defined in src/symple/src/server/detail.h:80
{#candirectmessage}
canDirectMessage
static nodiscard
[[nodiscard]] static bool canDirectMessage(const ServerPeer & sender, const ServerPeer & recipient)
Defined in src/symple/src/server/detail.h:82
{#candirectmessage-1}
canDirectMessage
static nodiscard
[[nodiscard]] static bool canDirectMessage(const ServerPeer & sender, const VirtualPeer & recipient)
Defined in src/symple/src/server/detail.h:84
{#canbroadcasttoroom}
canBroadcastToRoom
static nodiscard
[[nodiscard]] static bool canBroadcastToRoom(const ServerPeer & sender, const std::string & room)
Defined in src/symple/src/server/detail.h:86
{#serverpeer}
ServerPeer
#include <icy/symple/server.h>
class ServerPeer
Defined in src/symple/include/icy/symple/server.h:43
Per-connection state for a connected Symple peer.
Created by the server after successful authentication. Holds the peer data, room memberships, and a reference to the underlying WebSocket connection for sending.
List of all members
| Name | Kind | Owner |
|---|---|---|
ServerPeer | function | Declared here |
send | function | Declared here |
sendSerialized | function | Declared here |
join | function | Declared here |
leave | function | Declared here |
leaveAll | function | Declared here |
peer | function | Declared here |
peer | function | Declared here |
id | function | Declared here |
rooms | function | Declared here |
authenticated | function | Declared here |
setAuthenticated | function | Declared here |
setPeer | function | Declared here |
connection | function | Declared here |
checkRate | function | Declared here |
setRateLimit | function | Declared here |
_conn | variable | Declared here |
_peer | variable | Declared here |
_rooms | variable | Declared here |
_rateLimiter | variable | Declared here |
_authenticated | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
ServerPeer | Constructs a peer bound to the given server-side connection. | |
void | send | Serialises and sends a JSON message over the WebSocket connection. Logs a warning if the send fails; does not throw. |
void | sendSerialized | Sends a pre-serialized JSON payload over the WebSocket connection. Use this on fanout paths that already serialized once. |
void | join | Adds this peer to the named room (local tracking only). |
void | leave | Removes this peer from the named room (local tracking only). |
void | leaveAll | Removes this peer from all rooms (local tracking only). |
Peer & | peer inline nodiscard | Returns a mutable reference to the peer data object. |
const Peer & | peer const inline nodiscard | Returns a const reference to the peer data object. |
std::string | id const nodiscard | Returns the session ID assigned to this peer. |
const std::unordered_set< std::string > & | rooms const inline nodiscard | Returns the set of room names this peer is currently joined to. |
bool | authenticated const inline nodiscard | Returns true if the peer has completed authentication. |
void | setAuthenticated inline | Marks the peer as authenticated or unauthenticated. |
void | setPeer inline | Replaces the peer's data object. |
http::ServerConnection & | connection inline | Returns a reference to the underlying server connection. |
bool | checkRate inline nodiscard | Per-peer rate limiter. Returns false if message should be dropped. |
void | setRateLimit inline | Configures the per-peer rate limit. |
{#serverpeer-1}
ServerPeer
ServerPeer(http::ServerConnection & conn)
Defined in src/symple/include/icy/symple/server.h:48
Constructs a peer bound to the given server-side connection.
Parameters
connThe underlying WebSocket server connection.
{#send-19}
send
void send(const json::Value & msg)
Defined in src/symple/include/icy/symple/server.h:53
Serialises and sends a JSON message over the WebSocket connection. Logs a warning if the send fails; does not throw.
Parameters
msgJSON value to send.
{#sendserialized}
sendSerialized
void sendSerialized(const char * data, size_t len)
Defined in src/symple/include/icy/symple/server.h:57
Sends a pre-serialized JSON payload over the WebSocket connection. Use this on fanout paths that already serialized once.
{#join-1}
join
void join(const std::string & room)
Defined in src/symple/include/icy/symple/server.h:61
Adds this peer to the named room (local tracking only).
Parameters
roomRoom name to join.
{#leave-1}
leave
void leave(const std::string & room)
Defined in src/symple/include/icy/symple/server.h:65
Removes this peer from the named room (local tracking only).
Parameters
roomRoom name to leave.
{#leaveall-1}
leaveAll
void leaveAll()
Defined in src/symple/include/icy/symple/server.h:68
Removes this peer from all rooms (local tracking only).
{#peer-6}
peer
inline nodiscard
[[nodiscard]] inline Peer & peer()
Defined in src/symple/include/icy/symple/server.h:71
Returns a mutable reference to the peer data object.
{#peer-7}
peer
const inline nodiscard
[[nodiscard]] inline const Peer & peer() const
Defined in src/symple/include/icy/symple/server.h:74
Returns a const reference to the peer data object.
{#id-9}
id
const nodiscard
[[nodiscard]] std::string id() const
Defined in src/symple/include/icy/symple/server.h:77
Returns the session ID assigned to this peer.
{#rooms-2}
rooms
const inline nodiscard
[[nodiscard]] inline const std::unordered_set< std::string > & rooms() const
Defined in src/symple/include/icy/symple/server.h:80
Returns the set of room names this peer is currently joined to.
{#authenticated}
authenticated
const inline nodiscard
[[nodiscard]] inline bool authenticated() const
Defined in src/symple/include/icy/symple/server.h:83
Returns true if the peer has completed authentication.
{#setauthenticated}
setAuthenticated
inline
inline void setAuthenticated(bool v)
Defined in src/symple/include/icy/symple/server.h:87
Marks the peer as authenticated or unauthenticated.
Parameters
vTrue to mark as authenticated.
{#setpeer}
setPeer
inline
inline void setPeer(const Peer & p)
Defined in src/symple/include/icy/symple/server.h:91
Replaces the peer's data object.
Parameters
pNew peer data.
{#connection-10}
connection
inline
inline http::ServerConnection & connection()
Defined in src/symple/include/icy/symple/server.h:94
Returns a reference to the underlying server connection.
{#checkrate}
checkRate
inline nodiscard
[[nodiscard]] inline bool checkRate()
Defined in src/symple/include/icy/symple/server.h:97
Per-peer rate limiter. Returns false if message should be dropped.
{#setratelimit}
setRateLimit
inline
inline void setRateLimit(double rate, double seconds)
Defined in src/symple/include/icy/symple/server.h:102
Configures the per-peer rate limit.
Parameters
-
rateMaximum messages allowed per window. -
secondsDuration of the rate window in seconds.
Private Attributes
| Return | Name | Description |
|---|---|---|
http::ServerConnection & | _conn | |
Peer | _peer | |
std::unordered_set< std::string > | _rooms | |
RateLimiter | _rateLimiter | 100 messages per 10 seconds default |
bool | _authenticated |
{#_conn}
_conn
http::ServerConnection & _conn
Defined in src/symple/include/icy/symple/server.h:109
{#_peer-1}
_peer
Peer _peer
Defined in src/symple/include/icy/symple/server.h:110
{#_rooms-1}
_rooms
std::unordered_set< std::string > _rooms
Defined in src/symple/include/icy/symple/server.h:111
{#_ratelimiter}
_rateLimiter
RateLimiter _rateLimiter {100.0, 10.0}
Defined in src/symple/include/icy/symple/server.h:112
100 messages per 10 seconds default
{#_authenticated}
_authenticated
bool _authenticated = false
Defined in src/symple/include/icy/symple/server.h:113
{#address-13}
Address
#include <icy/symple/address.h>
struct Address
Defined in src/symple/include/icy/symple/address.h:28
The Address structure is an endpoint identifier for a peer on the network. The format is like so: user|id
List of all members
| Name | Kind | Owner |
|---|---|---|
operator<< | friend | Declared here |
user | variable | Declared here |
id | variable | Declared here |
Address | function | Declared here |
Address | function | Declared here |
Address | function | Declared here |
parse | function | Declared here |
valid | function | Declared here |
print | function | Declared here |
toString | function | Declared here |
operator== | function | Declared here |
operator== | function | Declared here |
Friends
| Name | Description |
|---|---|
operator<< inline |
{#operator-34}
operator<<
inline
friend inline std::ostream & operator<<(std::ostream & os, const Address & addr)
Defined in src/symple/include/icy/symple/address.h:71
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | user | |
std::string | id |
{#user}
user
std::string user
Defined in src/symple/include/icy/symple/address.h:77
{#id-5}
id
std::string id
Defined in src/symple/include/icy/symple/address.h:79
Public Methods
| Return | Name | Description |
|---|---|---|
Address | Constructs an empty (invalid) address. | |
Address | Parses an address string of the form user|id. | |
Address | Constructs an address from explicit user and session ID components. | |
bool | parse | Parses an address string of the form user|id. Populates the [user](#user) and [id](#id-5) fields. |
bool | valid const nodiscard | Returns true if at least one of [user](#user) or [id](#id-5) is non-empty. |
void | print const | Writes the address in user|id format to the given stream. |
std::string | toString const nodiscard | Returns the address as a string in user|id format. |
bool | operator== const | Compares two addresses for equality (both user and id must match). |
bool | operator== const | Compares this address against a string in user|id format without allocating. |
{#address-14}
Address
Address()
Defined in src/symple/include/icy/symple/address.h:32
Constructs an empty (invalid) address.
{#address-15}
Address
Address(std::string_view addr)
Defined in src/symple/include/icy/symple/address.h:36
Parses an address string of the form user|id.
Parameters
addrAddress string to parse.
{#address-16}
Address
Address(const std::string & user, const std::string & id)
Defined in src/symple/include/icy/symple/address.h:41
Constructs an address from explicit user and session ID components.
Parameters
-
userUser identifier. -
idSession ID.
{#parse-2}
parse
bool parse(std::string_view addr)
Defined in src/symple/include/icy/symple/address.h:50
Parses an address string of the form user|id. Populates the [user](#user) and [id](#id-5) fields.
Parameters
addrAddress string to parse.
Returns
True if the result is a valid address.
{#valid-10}
valid
const nodiscard
[[nodiscard]] bool valid() const
Defined in src/symple/include/icy/symple/address.h:53
Returns true if at least one of [user](#user) or [id](#id-5) is non-empty.
{#print-15}
const
void print(std::ostream & os) const
Defined in src/symple/include/icy/symple/address.h:57
Writes the address in user|id format to the given stream.
Parameters
osOutput stream.
{#tostring-9}
toString
const nodiscard
[[nodiscard]] std::string toString() const
Defined in src/symple/include/icy/symple/address.h:61
Returns the address as a string in user|id format.
Returns
Serialised address string.
{#operator-35}
operator==
const
bool operator==(const Address & r) const
Defined in src/symple/include/icy/symple/address.h:65
Compares two addresses for equality (both user and id must match).
Parameters
rAddress to compare against.
{#operator-36}
operator==
const
bool operator==(const std::string & r) const
Defined in src/symple/include/icy/symple/address.h:69
Compares this address against a string in user|id format without allocating.
Parameters
rString to compare against.
{#clientstate-1}
ClientState
#include <icy/symple/client.h>
struct ClientState
Defined in src/symple/include/icy/symple/client.h:38
Inherits:
State
Client connection states.
List of all members
| Name | Kind | Owner |
|---|---|---|
str | function | Declared here |
Type | enum | Declared here |
ID | typedef | Inherited from State |
_id | variable | Inherited from State |
State | function | Inherited from State |
State | function | Inherited from State |
operator= | function | Inherited from State |
~State | function | Inherited from State |
id | function | Inherited from State |
set | function | Inherited from State |
str | function | Inherited from State |
toString | function | Inherited from State |
equals | function | Inherited from State |
between | function | Inherited from State |
operator== | function | Inherited from State |
operator== | function | Inherited from State |
operator<< | friend | Inherited from State |
Inherited from State
| Kind | Name | Description |
|---|---|---|
typedef | ID | |
variable | _id | |
function | State | |
function | State | Copy constructor. |
function | operator= | Copy assignment. |
function | ~State virtual | Defaulted destructor. |
function | id const | Returns the current state ID. |
function | set | Sets the state ID. |
function | str virtual const | Returns a human-readable string for the given state ID. Override in derived classes to provide meaningful names. |
function | toString virtual const | Returns a human-readable string for the current state ID. |
function | equals const | Returns true if the current state ID equals the given ID. |
function | between const | Returns true if the current state ID is in the inclusive range [lid, rid]. |
function | operator== const inline | |
function | operator== const inline | |
friend | operator<< inline |
Public Methods
| Return | Name | Description |
|---|---|---|
std::string | str const inline override |
{#str-3}
str
const inline override
inline std::string str(unsigned int id) const override
Defined in src/symple/include/icy/symple/client.h:49
Public Types
| Name | Description |
|---|---|
Type |
{#type-20}
Type
enum Type
Defined in src/symple/include/icy/symple/client.h:40
| Value | Description |
|---|---|
Closed | |
Connecting | |
Authenticating | |
Online | |
Error |