Action Engine
Loading...
Searching...
No Matches
act::net::WebRtcServer Class Reference

Detailed Description

Represents an acceptor for WebRTC data channels, opening an act::Service instance for incoming connections.

This class is designed to handle incoming WebRTC data channel connections, which it accepts through a signalling server, turning successfully accepted connections into WebRtcWireStream instances. The WireStream instances are then passed to the act::Service for further processing.

The server abstraction in Action Engine is intentionally not standardised across all protocols, and it is only expected from the server to accept incoming connections and pass them to the service. The service is expected to handle the connections, including sending and receiving wire messages, managing the lifecycle of the connections, and handling any logical errors that may occur during the communication.

Protocol-specific lifecycle management is better handled by the WireStream implementation and not by the server itself. Server implementations may take care of other considerations, such as security, load balancing, access and flow control, and are unrestricted in doing so.

#include <actionengine/net/webrtc/server.h>

Public Member Functions

 WebRtcServer (act::Service *absl_nonnull service, std::string_view address="0.0.0.0", uint16_t port=20000, std::string_view signalling_address="localhost", uint16_t signalling_port=80, std::string_view signalling_identity="server", std::optional< RtcConfig > rtc_config=std::nullopt)
 
void Run ()
 
absl::Status Cancel ()
 
absl::Status Join ()
 

Constructor & Destructor Documentation

◆ WebRtcServer()

act::net::WebRtcServer::WebRtcServer ( act::Service *absl_nonnull service,
std::string_view address = "0.0.0.0",
uint16_t port = 20000,
std::string_view signalling_address = "localhost",
uint16_t signalling_port = 80,
std::string_view signalling_identity = "server",
std::optional< RtcConfig > rtc_config = std::nullopt )
explicit

Constructs a WebRtcServer instance.

Parameters
serviceThe act::Service instance which will handle the WireStream instances created by this server from incoming WebRTC data channel connections.
addressThe address to bind the server to. Defaults to 0.0.0.0, which means the server will accept connections on all available interfaces.
portThe port to bind the server to. Defaults to 20000.
signalling_addressThe address of the signalling server to connect to. Defaults to localhost.
signalling_portThe port of the signalling server to connect to. Defaults to 80.
signalling_identityThe identity of the server in the signalling server. Defaults to server. This identity is used to identify the server in the signalling server and to establish connections with clients.
Note
Notice that no special measures are taken to protect the server's identity, so in production setups, signalling servers MUST make sure that the identity cannot be impersonated by a malicious client.
Parameters
rtc_configOptional configuration for the WebRTC connections. If not provided, a default configuration will be used. The configuration can include settings such as STUN/TURN servers, port ranges, and other WebRTC parameters.

Member Function Documentation

◆ Cancel()

absl::Status act::net::WebRtcServer::Cancel ( )

Cancels the WebRTC server, stopping loop that accepts incoming connections.

Note that by itself, this does not close any existing WireStream instances or connections. It simply stops accepting new connections. The act::Service instance will continue working normally unless and until it is also cancelled or goes out of scope.

Returns
An OK status.

◆ Join()

absl::Status act::net::WebRtcServer::Join ( )

Joins the WebRTC server, waiting for the main loop that accepts incoming connections to finish running.

Returns
An OK status if the main loop has finished successfully, or an error status if there was an issue at some point during the execution of the main loop.

◆ Run()

void act::net::WebRtcServer::Run ( )

Starts the WebRTC server, accepting incoming connections and processing them in a loop.

Accepted connections are turned into WebRtcWireStream instances, which are then passed to the act::Service to perform application logic, session management, and error handling.

This method does not block the caller, but instead runs in a separate fiber. That fiber will continue to run until the server is cancelled by calling Cancel(), and can be joined by calling Join().


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