Sunshine master
Self-hosted game stream host for Moonlight.
stream::control_server_t Class Reference

ENet control server that routes incoming control packets to stream sessions. More...

Collaboration diagram for stream::control_server_t:
[legend]

Public Member Functions

int bind (net::af_e address_family, std::uint16_t port)
 Bind the underlying socket or graphics resource to its target.
 
void call (std::uint16_t type, session_t *session, const std::string_view &payload, bool reinjected)
 Call the handler for a given control stream message.
 
void flush ()
 Flush pending packets to the stream socket.
 
session_tget_session (const net::peer_t peer, uint32_t connect_data)
 Return the session value from the backend.
 
void iterate (std::chrono::milliseconds timeout)
 Visit each active control server session.
 
void map (uint16_t type, std::function< void(session_t *, const std::string_view &)> cb)
 Register or visit handlers stored in the map.
 
int send (const std::string_view &payload, net::peer_t peer)
 Send the serialized response over the active socket.
 

Public Attributes

ENetAddress _addr
 Local ENet address used by the control channel.
 
net::host_t _host
 ENet host object that owns the control socket.
 
std::unordered_map< std::uint16_t, std::function< void(session_t *, const std::string_view &)> > _map_type_cb
 Control-message handlers keyed by packet type.
 
sync_util::sync_t< std::map< net::peer_t, session_t * > > _peer_to_session
 Peer to session.
 
sync_util::sync_t< std::vector< session_t * > > _sessions
 Active sessions registered with the control server.
 

Detailed Description

ENet control server that routes incoming control packets to stream sessions.

Member Function Documentation

◆ bind()

int stream::control_server_t::bind ( net::af_e address_family,
std::uint16_t port )
inline

Bind the underlying socket or graphics resource to its target.

Parameters
address_familyAddress family.
portTCP or UDP port number.
Returns
Network operation status.

◆ call()

void stream::control_server_t::call ( std::uint16_t type,
session_t * session,
const std::string_view & payload,
bool reinjected )

Call the handler for a given control stream message.

Parameters
typeThe message type.
sessionThe session the message was received on.
payloadThe payload of the message.
reinjectedtrue if this message is being reprocessed after decryption.

◆ get_session()

session_t * stream::control_server_t::get_session ( const net::peer_t peer,
uint32_t connect_data )

Return the session value from the backend.

Parameters
peerRemote endpoint associated with the socket.
connect_dataConnect data.
Returns
Existing session for the peer/connect-data pair, or nullptr when none matches.

◆ iterate()

void stream::control_server_t::iterate ( std::chrono::milliseconds timeout)

Visit each active control server session.

Parameters
timeoutMaximum time to wait for the operation.

◆ map()

void stream::control_server_t::map ( uint16_t type,
std::function< void(session_t *, const std::string_view &)> cb )
inline

Register or visit handlers stored in the map.

Parameters
typeProtocol, message, or resource type selector.
cbCallback invoked for each matching message or session.

◆ send()

int stream::control_server_t::send ( const std::string_view & payload,
net::peer_t peer )
inline

Send the serialized response over the active socket.

Parameters
payloadOptional payload body to include in the response.
peerRemote endpoint associated with the socket.
Returns
Network operation status.

The documentation for this class was generated from the following file: