WebsocketConnection
Object Hierarchy:
Soup.WebsocketConnection
Soup.WebsocketConnection
Soup.WebsocketConnection
GLib.Object
GLib.Object
GLib.Object->Soup.WebsocketConnection
Description:
[ CCode ( type_id = "soup_websocket_connection_get_type ()" ) ]public sealed class WebsocketConnection : Object
The WebSocket Protocol
Provides support for the WebSocket protocol.
To connect to a WebSocket server, create a [class@Session] and call [[email protected] _connect_async]. To accept WebSocket
connections, create a [class@Server] and add a handler to it with [[email protected] _websocket_handler].
(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.)
WebsocketConnection handles the details of WebSocket communication. You can use [
[email protected] _text] and [[email protected] _binary] to send data, and the [signal@WebsocketConnection:
SoupWebsocketConnection:message
] signal to receive data. (WebsocketConnection currently only
supports asynchronous I/O.)
Content:
Properties:
public WebsocketConnectionType connection_type { get ; construct ; }
The type of connection (client/server).
public void * extensions { get ; construct ; }
List of [class@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.
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:
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 signal void closed ()
Emitted when the connection has completely closed.
public signal void closing ()
This signal will be emitted during an orderly close.
public signal void error (Error error)
Emitted when an error occurred on the WebSocket.
public signal void message (int type, Bytes message)
Emitted when we receive a message from the peer.
public 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
@get
@new
@ref
@set
add_toggle_ref
add_weak_pointer
bind_property
connect
constructed
disconnect
dispose
dup_data
dup_qdata
force_floating
freeze_notify
get_class
get_data
get_property
get_qdata
get_type
getv
interface_find_property
interface_install_property
interface_list_properties
is_floating
new_valist
new_with_properties
newv
notify
notify_property
ref_count
ref_sink
remove_toggle_ref
remove_weak_pointer
replace_data
replace_qdata
set_data
set_data_full
set_property
set_qdata
set_qdata_full
set_valist
setv
steal_data
steal_qdata
thaw_notify
unref
watch_closure
weak_ref
weak_unref