#include <icy/symple/server.h>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.
| 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 | Returns a mutable reference to the peer data object. |
const Peer & | peer const inline | Returns a const reference to the peer data object. |
std::string | id const | Returns the session ID assigned to this peer. |
const std::unordered_set< std::string > & | rooms const inline | Returns the set of room names this peer is currently joined to. |
bool | authenticated const inline | 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 | Per-peer rate limiter. Returns false if message should be dropped. |
void | setRateLimit inline | Configures the per-peer rate limit. |
ServerPeer(http::ServerConnection & conn)Constructs a peer bound to the given server-side connection.
conn The underlying WebSocket server connection.void send(const json::Value & msg)Serialises and sends a JSON message over the WebSocket connection. Logs a warning if the send fails; does not throw.
msg JSON value to send.void sendSerialized(const char * data, size_t len)Sends a pre-serialized JSON payload over the WebSocket connection. Use this on fanout paths that already serialized once.
void join(const std::string & room)Adds this peer to the named room (local tracking only).
room Room name to join.void leave(const std::string & room)Removes this peer from the named room (local tracking only).
room Room name to leave.void leaveAll()Removes this peer from all rooms (local tracking only).
inline
inline Peer & peer()Returns a mutable reference to the peer data object.
const inline
inline const Peer & peer() constReturns a const reference to the peer data object.
const
std::string id() constReturns the session ID assigned to this peer.
const inline
inline const std::unordered_set< std::string > & rooms() constReturns the set of room names this peer is currently joined to.
const inline
inline bool authenticated() constReturns true if the peer has completed authentication.
inline
inline void setAuthenticated(bool v)Marks the peer as authenticated or unauthenticated.
v True to mark as authenticated.inline
inline void setPeer(const Peer & p)Replaces the peer's data object.
p New peer data.inline
inline http::ServerConnection & connection()Returns a reference to the underlying server connection.
inline
inline bool checkRate()Per-peer rate limiter. Returns false if message should be dropped.
inline
inline void setRateLimit(double rate, double seconds)Configures the per-peer rate limit.
rate Maximum messages allowed per window.
seconds Duration of the rate window in seconds.
| Return | Name | Description |
|---|---|---|
http::ServerConnection & | _conn | |
Peer | _peer | |
std::unordered_set< std::string > | _rooms | |
RateLimiter | _rateLimiter | 100 messages per 10 seconds default |
bool | _authenticated |
http::ServerConnection & _connPeer _peerstd::unordered_set< std::string > _roomsRateLimiter _rateLimiter {100.0, 10.0}100 messages per 10 seconds default
bool _authenticated = false