ServerPeer
ServerPeer
#include <icy/symple/server.h>class ServerPeerDefined 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 | 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
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
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
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
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
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
void leaveAll()Defined in src/symple/include/icy/symple/server.h:68
Removes this peer from all rooms (local tracking only).
peer
inline
inline Peer & peer()Defined in src/symple/include/icy/symple/server.h:71
Returns a mutable reference to the peer data object.
peer
const inline
inline const Peer & peer() constDefined in src/symple/include/icy/symple/server.h:74
Returns a const reference to the peer data object.
id
const
std::string id() constDefined in src/symple/include/icy/symple/server.h:77
Returns the session ID assigned to this peer.
rooms
const inline
inline const std::unordered_set< std::string > & rooms() constDefined in src/symple/include/icy/symple/server.h:80
Returns the set of room names this peer is currently joined to.
authenticated
const inline
inline bool authenticated() constDefined in src/symple/include/icy/symple/server.h:83
Returns true if the peer has completed authentication.
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
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
inline
inline http::ServerConnection & connection()Defined in src/symple/include/icy/symple/server.h:94
Returns a reference to the underlying server connection.
checkRate
inline
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
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
http::ServerConnection & _connDefined in src/symple/include/icy/symple/server.h:109
_peer
Peer _peerDefined in src/symple/include/icy/symple/server.h:110
_rooms
std::unordered_set< std::string > _roomsDefined in src/symple/include/icy/symple/server.h:111
_rateLimiter
RateLimiter _rateLimiter {100.0, 10.0}Defined in src/symple/include/icy/symple/server.h:112
100 messages per 10 seconds default
_authenticated
bool _authenticated = false