Method
SoupServeradd_websocket_handler
Declaration [src]
void
soup_server_add_websocket_handler (
SoupServer* server,
const char* path,
const char* origin,
char** protocols,
SoupServerWebsocketCallback callback,
gpointer user_data,
GDestroyNotify destroy
)
Description [src]
Adds a WebSocket handler to server for requests prefixed by path.
If path is NULL or “/”, then this will be the default handler for all
requests that don’t have a more specific handler.
When a path has a WebSocket handler registered, server will check
incoming requests for WebSocket handshakes after all other handlers
have run (unless some earlier handler has already set a status code
on the message), and update the request’s status, response headers,
and response body accordingly.
If origin is non-NULL, then only requests containing a matching
“Origin” header will be accepted. If protocols is non-NULL, then
only requests containing a compatible “Sec-WebSocket-Protocols”
header will be accepted. More complicated requirements can be
handled by adding a normal handler to path, and having it perform
whatever checks are needed and
setting a failure status code if the handshake should be rejected.
Parameters
path-
Type:
const char*The toplevel path for the handler.
The argument can be NULL.The data is owned by the caller of the method. The value is a NUL terminated UTF-8 string. origin-
Type:
const char*The origin of the connection.
The argument can be NULL.The data is owned by the caller of the method. The value is a NUL terminated UTF-8 string. protocols-
Type: An array of
char*The protocols supported by this handler.
The argument can be NULL.The array must be NULL-terminated.The data is owned by the caller of the method. Each element is a NUL terminated UTF-8 string. callback-
Type:
SoupServerWebsocketCallbackCallback to invoke for successful WebSocket requests under
path. user_data-
Type:
gpointerData for
callback.The argument can be NULL.The data is owned by the caller of the method. destroy-
Type:
GDestroyNotifyDestroy notifier to free
user_data.