|
@@ -504,6 +504,10 @@ If `buffer` is `NULL`, the description is not copied but the size is still retur
|
|
```
|
|
```
|
|
int rtcCreateWebSocket(const char *url)
|
|
int rtcCreateWebSocket(const char *url)
|
|
int rtcCreateWebSocketEx(const char *url, const rtcWsConfiguration *config)
|
|
int rtcCreateWebSocketEx(const char *url, const rtcWsConfiguration *config)
|
|
|
|
+
|
|
|
|
+typedef struct {
|
|
|
|
+ bool disableTlsVerification; // if true, disable TLS certificate verification
|
|
|
|
+} rtcWsConfiguration;
|
|
```
|
|
```
|
|
|
|
|
|
Creates a new client WebSocket.
|
|
Creates a new client WebSocket.
|
|
@@ -526,11 +530,100 @@ int rtcDeleteWebSocket(int ws)
|
|
Arguments:
|
|
Arguments:
|
|
- `ws`: the identifier of the WebSocket to delete
|
|
- `ws`: the identifier of the WebSocket to delete
|
|
|
|
|
|
-Return value: the identifier of the new WebSocket or a negative error code
|
|
|
|
-
|
|
|
|
After this function has been called, `ws` must not be used in a function call anymore. This function will block until all scheduled callbacks of `ws` return (except the one this function might be called in) and no other callback will be called for `ws` after it returns.
|
|
After this function has been called, `ws` must not be used in a function call anymore. This function will block until all scheduled callbacks of `ws` return (except the one this function might be called in) and no other callback will be called for `ws` after it returns.
|
|
|
|
|
|
-### Channel (Data Channel, Track, and WebSocket)
|
|
|
|
|
|
+#### rtcGetWebSocketRemoteAddress
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+int rtcGetWebSocketRemoteAddress(int ws, char *buffer, int size)
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+Retrieves the remote address, i.e. the network address of the remote endpoint. The address will have the format `"HOST:PORT"`. The call may fail if the underlying TCP transport of the WebSocket is not connected. This function is useful for a client WebSocket received by a WebSocket Server.
|
|
|
|
+
|
|
|
|
+Arguments:
|
|
|
|
+- `ws`: the identifier of the WebSocket
|
|
|
|
+- `buffer`: a user-supplied buffer to store the description
|
|
|
|
+- `size`: the size of `buffer`
|
|
|
|
+
|
|
|
|
+Return value: the length of the string copied in buffer (including the terminating null character) or a negative error code
|
|
|
|
+
|
|
|
|
+If `buffer` is `NULL`, the address is not copied but the size is still returned.
|
|
|
|
+
|
|
|
|
+#### rtcGetWebSocketPath
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+int rtcGetWebSocketPath(int ws, char *buffer, int size)
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+Retrieves the path of the WebSocket, i.e. the HTTP requested path. This function is useful for a client WebSocket received by a WebSocket Server. Warning: The WebSocket must be open for the call to succeed.
|
|
|
|
+
|
|
|
|
+Arguments:
|
|
|
|
+- `ws`: the identifier of the WebSocket
|
|
|
|
+- `buffer`: a user-supplied buffer to store the description
|
|
|
|
+- `size`: the size of `buffer`
|
|
|
|
+
|
|
|
|
+Return value: the length of the string copied in buffer (including the terminating null character) or a negative error code
|
|
|
|
+
|
|
|
|
+If `buffer` is `NULL`, the path is not copied but the size is still returned.
|
|
|
|
+
|
|
|
|
+### WebSocket Server
|
|
|
|
+
|
|
|
|
+#### rtcCreateWebSocketServer
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+int rtcCreateWebSocketServer(const rtcWsServerConfiguration *config, rtcWebSocketClientCallbackFunc cb);
|
|
|
|
+
|
|
|
|
+typedef struct {
|
|
|
|
+ uint16_t port;
|
|
|
|
+ bool enableTls;
|
|
|
|
+ const char *certificatePemFile; // NULL for autogenerated certificate
|
|
|
|
+ const char *keyPemFile; // NULL for autogenerated certificate
|
|
|
|
+ const char *keyPemPass; // NULL if no pass
|
|
|
|
+} rtcWsServerConfiguration;
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+Creates a new WebSocket server.
|
|
|
|
+
|
|
|
|
+Arguments:
|
|
|
|
+- `config`: a structure with the following parameters:
|
|
|
|
+ - `uint16_t port`: the port to listen on (if 0, automatically select an available port)
|
|
|
|
+ - `bool enableTls`: if true, enable the TLS layer (WSS)
|
|
|
|
+ - `const char *certificatePemFile`: path of the file containing the TLS PEM certificate (`NULL` for an autogenerated certificate)
|
|
|
|
+ - `const char *keyPemFile`: path of the file containing the TLS PEM key (`NULL` for an autogenerated certificate)
|
|
|
|
+ - `const char *keyPemPass`: the TLS PEM key passphrase (NULL if no passphrase)
|
|
|
|
+- `cb`: the callback for incoming client WebSocket connections (must not be `NULL`)
|
|
|
|
+
|
|
|
|
+`cb` must have the following signature: `void rtcWebSocketClientCallbackFunc(int wsserver, int ws, void *user_ptr)`
|
|
|
|
+
|
|
|
|
+Return value: the identifier of the new WebSocket Server or a negative error code
|
|
|
|
+
|
|
|
|
+The new WebSocket Server must be deleted with `rtcDeleteWebSocketServer`.
|
|
|
|
+
|
|
|
|
+#### rtcDeleteWebSocketServer
|
|
|
|
+
|
|
|
|
+```
|
|
|
|
+int rtcDeleteWebSocketServer(int wsserver)
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+Arguments:
|
|
|
|
+- `wsserver`: the identifier of the WebSocket Server to delete
|
|
|
|
+
|
|
|
|
+After this function has been called, `wsserver` must not be used in a function call anymore. This function will block until all scheduled callbacks of `wsserver` return (except the one this function might be called in) and no other callback will be called for `wsserver` after it returns.
|
|
|
|
+
|
|
|
|
+#### rtcGetWebSocketServerPort
|
|
|
|
+```
|
|
|
|
+int rtcGetWebSocketServerPort(int wsserver);
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+Retrieves the port which the WebSocket Server is listening on.
|
|
|
|
+
|
|
|
|
+Arguments:
|
|
|
|
+- `wsserver`: the identifier of the WebSocket Server
|
|
|
|
+
|
|
|
|
+Return value: The port of the WebSocket Server or a negative error code
|
|
|
|
+
|
|
|
|
+### Channel (Common API for Data Channel, Track, and WebSocket)
|
|
|
|
|
|
The following common functions might be called with a generic channel identifier. It may be the identifier of either a Data Channel, a Track, or a WebSocket.
|
|
The following common functions might be called with a generic channel identifier. It may be the identifier of either a Data Channel, a Track, or a WebSocket.
|
|
|
|
|