WebsocketConnection
Object Hierarchy:
Description:
[ CCode ( type_id = "soup_websocket_connection_get_type ()" ) ]
[ Version ( since = "2.50" ) ]
public class WebsocketConnection : Object
[ Version ( since = "2.50" ) ]
public class WebsocketConnection : Object
A class representing a WebSocket connection.
Namespace: Soup
Package: libsoup-2.4
Content:
Properties:
- public WebsocketConnectionType connection_type { get; construct; }
The type of connection (client/server).
- public void* extensions { get; construct; }
List of WebsocketExtension objects that are active in the connection.
- public IOStream io_stream { get; construct; }
The underlying IO stream the WebSocket is communicating over.
- public uint keepalive_interval { get; set construct; }
Interval in seconds on when to send a ping message which will serve as a keepalive message.
- public uint64 max_incoming_payload_size { get; set construct; }
The maximum payload size for incoming packets the protocol expects or 0 to not limit it.
- public string origin { get; construct; }
The client's Origin.
- public string protocol { get; construct; }
The chosen protocol, or
null
if a protocol was not agreed upon. - public WebsocketState state { get; }
The current state of the WebSocket.
- public URI uri { get; construct; }
The URI of the WebSocket.
Creation methods:
- public WebsocketConnection (IOStream stream, URI uri, WebsocketConnectionType type, string? origin, string? protocol)
Creates a WebsocketConnection on
stream
. - public WebsocketConnection.with_extensions (IOStream stream, URI uri, WebsocketConnectionType type, string? origin, string? protocol, owned List<WebsocketExtension> extensions)
Creates a WebsocketConnection on
stream
with the given activeextensions
.
Methods:
- public void close (ushort code, string? data)
Close the connection in an orderly fashion.
- public ushort get_close_code ()
Get the close code received from the WebSocket peer.
- public unowned string get_close_data ()
Get the close data received from the WebSocket peer.
- public WebsocketConnectionType get_connection_type ()
Get the connection type (client/server) of the connection.
- public unowned List<WebsocketExtension> get_extensions ()
Get the extensions chosen via negotiation with the peer.
- public unowned IOStream get_io_stream ()
Get the I/O stream the WebSocket is communicating over.
- public uint get_keepalive_interval ()
Gets the keepalive interval in seconds or 0 if disabled.
- public uint64 get_max_incoming_payload_size ()
Gets the maximum payload size allowed for incoming packets.
- public unowned string? get_origin ()
Get the origin of the WebSocket.
- public unowned string? get_protocol ()
Get the protocol chosen via negotiation with the peer.
- public WebsocketState get_state ()
Get the current state of the WebSocket.
- public unowned URI get_uri ()
Get the URI of the WebSocket.
- public void send_binary (uint8[]? data)
Send a binary message to the peer.
- public void send_message (WebsocketDataType type, Bytes message)
Send a message of the given
type
to the peer. - public void send_text (string text)
Send a
null
-terminated text (UTF-8) message to the peer. - public void set_keepalive_interval (uint interval)
Sets the interval in seconds on when to send a ping message which will serve as a keepalive message.
- public void set_max_incoming_payload_size (uint64 max_incoming_payload_size)
Sets the maximum payload size allowed for incoming packets.
Signals:
- public virtual signal void closed ()
Emitted when the connection has completely closed, either due to an orderly close from the peer, one initiated via close or a fatal error condition that caused a close.
- public virtual signal void closing ()
This signal will be emitted during an orderly close.
- public virtual signal void error (Error error)
Emitted when an error occurred on the WebSocket.
- public virtual signal void message (int type, Bytes message)
Emitted when we receive a message from the peer.
- public virtual signal void pong (Bytes message)
Emitted when we receive a Pong frame (solicited or unsolicited) from the peer.
Inherited Members:
All known members inherited from class GLib.Object