soup.websocket_connection

Module for [WebsocketConnection] class

Types 3

The WebSocket Protocol

Provides support for the WebSocket protocol.

To connect to a WebSocket server, create a soup.session.Session and call soup.session.Session.websocketConnectAsync. To accept WebSocket connections, create a soup.server.Server and add a handler to it with soup.server.Server.addWebsocketHandler.

(Lower-level support is available via func@websocket_client_prepare_handshake and func@websocket_client_verify_handshake, for handling the client side of the WebSocket handshake, and func@websocket_server_process_handshake for handling the server side.)

#SoupWebsocketConnection handles the details of WebSocket communication. You can use soup.websocket_connection.WebsocketConnection.sendText and soup.websocket_connection.WebsocketConnection.sendBinary to send data, and the soup.websocket_connection.WebsocketConnection.message signal to receive data. (#SoupWebsocketConnection currently only supports asynchronous I/O.)

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
WebsocketConnection self() nothrowReturns `this`, for use in `with` statements.
WebsocketConnectionGidBuilder builder() static nothrowGet builder for [soup.websocket_connection.WebsocketConnection] Returns: New builder object
soup.types.WebsocketConnectionType connectionType() @property nothrowGet `connectionType` property. Returns: The type of connection (client/server).
void * extensions() @property nothrowGet `extensions` property. Returns: List of [soup.websocket_extension.WebsocketExtension] objects that are active in the connection.
gio.iostream.IOStream ioStream() @property nothrowGet `ioStream` property. Returns: The underlying IO stream the WebSocket is communicating over.
uint keepaliveInterval() @property nothrowGet `keepaliveInterval` property. Returns: Interval in seconds on when to send a ping message which will serve as a keepalive message.
void keepaliveInterval(uint propval) @property nothrowSet `keepaliveInterval` property. Params: propval = Interval in seconds on when to send a ping message which will serve as a keepalive message.
ulong maxIncomingPayloadSize() @property nothrowGet `maxIncomingPayloadSize` property. Returns: The maximum payload size for incoming packets.
void maxIncomingPayloadSize(ulong propval) @property nothrowSet `maxIncomingPayloadSize` property. Params: propval = The maximum payload size for incoming packets.
string origin() @property nothrowGet `origin` property. Returns: The client's Origin.
string protocol() @property nothrowGet `protocol` property. Returns: The chosen protocol, or null if a protocol was not agreed upon.
soup.types.WebsocketState state() @property nothrowGet `state` property. Returns: The current state of the WebSocket.
glib.uri.Uri uri() @property nothrowGet `uri` property. Returns: The URI of the WebSocket.
void close(ushort code, string data = null) nothrowClose the connection in an orderly fashion.
ushort getCloseCode() nothrowGet the close code received from the WebSocket peer.
string getCloseData() nothrowGet the close data received from the WebSocket peer.
soup.types.WebsocketConnectionType getConnectionType() nothrowGet the connection type (client/server) of the connection. Returns: the connection type
soup.websocket_extension.WebsocketExtension[] getExtensions() nothrowGet the extensions chosen via negotiation with the peer. Returns: a #GList of #SoupWebsocketExtension objects
gio.iostream.IOStream getIoStream() nothrowGet the I/O stream the WebSocket is communicating over. Returns: the WebSocket's I/O stream.
uint getKeepaliveInterval() nothrowGets the keepalive interval in seconds or 0 if disabled. Returns: the keepalive interval.
ulong getMaxIncomingPayloadSize() nothrowGets the maximum payload size allowed for incoming packets. Returns: the maximum payload size.
string getOrigin() nothrowGet the origin of the WebSocket. Returns: the origin
string getProtocol() nothrowGet the protocol chosen via negotiation with the peer. Returns: the chosen protocol
soup.types.WebsocketState getState() nothrowGet the current state of the WebSocket. Returns: the state
glib.uri.Uri getUri() nothrowGet the URI of the WebSocket.
void sendBinary(ubyte[] data = null) nothrowSend a binary message to the peer.
void sendMessage(soup.types.WebsocketDataType type, glib.bytes.Bytes message) nothrowSend a message of the given type to the peer. Note that this method, allows to send text messages containing null characters.
void sendText(string text) nothrowSend a null-terminated text (UTF-8) message to the peer.
void setKeepaliveInterval(uint interval) nothrowSets the interval in seconds on when to send a ping message which will serve as a keepalive message.
void setMaxIncomingPayloadSize(ulong maxIncomingPayloadSize) nothrowSets the maximum payload size allowed for incoming packets.
gulong connectClosed(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.websocket_connection.WebsocketConnection))) && Parameters!T.length < 2) nothrowConnect to `Closed` signal.
gulong connectClosing(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : soup.websocket_connection.WebsocketConnection))) && Parameters!T.length < 2) nothrowConnect to `Closing` signal.
gulong connectError(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == glib.error.ErrorWrap))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : soup.websocket_connection.WebsocketConnection))) && Parameters!T.length < 3) nothrowConnect to `Error` signal.
gulong connectMessage(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == int))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == glib.bytes.Bytes))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : soup.websocket_connection.WebsocketConnection))) && Parameters!T.length < 4) nothrowConnect to `Message` signal.
gulong connectPong(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == glib.bytes.Bytes))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : soup.websocket_connection.WebsocketConnection))) && Parameters!T.length < 3) nothrowConnect to `Pong` signal.
Constructors
this(void * ptr, Flag!"Take" take)

Fluent builder implementation template for soup.websocket_connection.WebsocketConnection

Methods
T connectionType(soup.types.WebsocketConnectionType propval) nothrowSet `connectionType` property. Params: propval = The type of connection (client/server). Returns: Builder instance for fluent chaining
T extensions(void * propval) nothrowSet `extensions` property. Params: propval = List of [soup.websocket_extension.WebsocketExtension] objects that are active in the connection. Returns: Builder instance for fluent chaining
T ioStream(gio.iostream.IOStream propval) nothrowSet `ioStream` property. Params: propval = The underlying IO stream the WebSocket is communicating over.
T keepaliveInterval(uint propval) nothrowSet `keepaliveInterval` property. Params: propval = Interval in seconds on when to send a ping message which will serve as a keepalive message.
T maxIncomingPayloadSize(ulong propval) nothrowSet `maxIncomingPayloadSize` property. Params: propval = The maximum payload size for incoming packets.
T origin(string propval) nothrowSet `origin` property. Params: propval = The client's Origin. Returns: Builder instance for fluent chaining
T protocol(string propval) nothrowSet `protocol` property. Params: propval = The chosen protocol, or null if a protocol was not agreed upon. Returns: Builder instance for fluent chaining
T uri(glib.uri.Uri propval) nothrowSet `uri` property. Params: propval = The URI of the WebSocket.