| Action Engine
             | 
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 () | 
| 
 | explicit | 
Constructs a WebRtcServer instance.
| service | The act::Serviceinstance which will handle the WireStream instances created by this server from incoming WebRTC data channel connections. | 
| address | The address to bind the server to. Defaults to 0.0.0.0, which means the server will accept connections on all available interfaces. | 
| port | The port to bind the server to. Defaults to 20000. | 
| signalling_address | The address of the signalling server to connect to. Defaults to localhost. | 
| signalling_port | The port of the signalling server to connect to. Defaults to 80. | 
| signalling_identity | The 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. | 
| rtc_config | Optional 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. | 
| 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.
| absl::Status act::net::WebRtcServer::Join | ( | ) | 
Joins the WebRTC server, waiting for the main loop that accepts incoming connections to finish running.
| 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().