Server.addWebsocketHandler

Adds a WebSocket handler to @server for requests under @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 (possibly calling soup_server_check_websocket_handshake() one or more times), and setting a failure status code if the handshake should be rejected.

class Server
void
addWebsocketHandler
(
string path
,
string origin
,
string[] protocols
,,
void* userData
,
GDestroyNotify destroy
)

Parameters

path string

the toplevel path for the handler

origin string

the origin of the connection

protocols string[]

the protocols supported by this handler

callback SoupServerWebsocketCallback

callback to invoke for successful WebSocket requests under @path

userData void*

data for @callback

destroy GDestroyNotify

destroy notifier to free @user_data

Meta