gi-soup-2.4.24: Libsoup bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Soup.Objects.WebsocketConnection

Description

A class representing a WebSocket connection.

Since: 2.50

Synopsis

Exported types

newtype WebsocketConnection Source #

Memory-managed wrapper type.

Constructors

WebsocketConnection (ManagedPtr WebsocketConnection) 

Instances

Instances details
Eq WebsocketConnection Source # 
Instance details

Defined in GI.Soup.Objects.WebsocketConnection

GObject WebsocketConnection Source # 
Instance details

Defined in GI.Soup.Objects.WebsocketConnection

ManagedPtrNewtype WebsocketConnection Source # 
Instance details

Defined in GI.Soup.Objects.WebsocketConnection

TypedObject WebsocketConnection Source # 
Instance details

Defined in GI.Soup.Objects.WebsocketConnection

Methods

glibType :: IO GType

HasParentTypes WebsocketConnection Source # 
Instance details

Defined in GI.Soup.Objects.WebsocketConnection

IsGValue (Maybe WebsocketConnection) Source #

Convert WebsocketConnection to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Soup.Objects.WebsocketConnection

type ParentTypes WebsocketConnection Source # 
Instance details

Defined in GI.Soup.Objects.WebsocketConnection

type ParentTypes WebsocketConnection = '[Object]

class (GObject o, IsDescendantOf WebsocketConnection o) => IsWebsocketConnection o Source #

Type class for types which can be safely cast to WebsocketConnection, for instance with toWebsocketConnection.

Instances

Instances details
(GObject o, IsDescendantOf WebsocketConnection o) => IsWebsocketConnection o Source # 
Instance details

Defined in GI.Soup.Objects.WebsocketConnection

toWebsocketConnection :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketConnection Source #

Cast to WebsocketConnection, for types for which this is known to be safe. For general casts, use castTo.

Methods

close

websocketConnectionClose Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> Word16

code: close code

-> Maybe Text

data: close data

-> m () 

Close the connection in an orderly fashion.

Note that until the closed signal fires, the connection is not yet completely closed. The close message is not even sent until the main loop runs.

The code and data are sent to the peer along with the close request. If code is WebsocketCloseCodeNoStatus a close message with no body (without code and data) is sent. Note that the data must be UTF-8 valid.

Since: 2.50

getCloseCode

websocketConnectionGetCloseCode Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m Word16

Returns: the close code or zero.

Get the close code received from the WebSocket peer.

This only becomes valid once the WebSocket is in the WebsocketStateClosed state. The value will often be in the WebsocketCloseCode enumeration, but may also be an application defined close code.

Since: 2.50

getCloseData

websocketConnectionGetCloseData Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m Text

Returns: the close data or Nothing

Get the close data received from the WebSocket peer.

This only becomes valid once the WebSocket is in the WebsocketStateClosed state. The data may be freed once the main loop is run, so copy it if you need to keep it around.

Since: 2.50

getConnectionType

websocketConnectionGetConnectionType Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m WebsocketConnectionType

Returns: the connection type

Get the connection type (client/server) of the connection.

Since: 2.50

getExtensions

websocketConnectionGetExtensions Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m [WebsocketExtension]

Returns: a List of WebsocketExtension objects

Get the extensions chosen via negotiation with the peer.

Since: 2.68

getIoStream

websocketConnectionGetIoStream Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m IOStream

Returns: the WebSocket's I/O stream.

Get the I/O stream the WebSocket is communicating over.

Since: 2.50

getKeepaliveInterval

websocketConnectionGetKeepaliveInterval Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m Word32

Returns: the keepalive interval.

Gets the keepalive interval in seconds or 0 if disabled.

Since: 2.58

getMaxIncomingPayloadSize

websocketConnectionGetMaxIncomingPayloadSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m Word64

Returns: the maximum payload size.

Gets the maximum payload size allowed for incoming packets.

Since: 2.56

getOrigin

websocketConnectionGetOrigin Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m (Maybe Text)

Returns: the origin, or Nothing

Get the origin of the WebSocket.

Since: 2.50

getProtocol

websocketConnectionGetProtocol Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m (Maybe Text)

Returns: the chosen protocol, or Nothing

Get the protocol chosen via negotiation with the peer.

Since: 2.50

getState

websocketConnectionGetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m WebsocketState

Returns: the state

Get the current state of the WebSocket.

Since: 2.50

getUri

websocketConnectionGetUri Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> m URI

Returns: the URI

Get the URI of the WebSocket.

For servers this represents the address of the WebSocket, and for clients it is the address connected to.

Since: 2.50

new

websocketConnectionNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsIOStream a) 
=> a

stream: a IOStream connected to the WebSocket server

-> URI

uri: the URI of the connection

-> WebsocketConnectionType

type: the type of connection (client/side)

-> Maybe Text

origin: the Origin of the client

-> Maybe Text

protocol: the subprotocol in use

-> m WebsocketConnection

Returns: a new WebsocketConnection

Creates a WebsocketConnection on stream. This should be called after completing the handshake to begin using the WebSocket protocol.

Since: 2.50

newWithExtensions

websocketConnectionNewWithExtensions Source #

Arguments

:: (HasCallStack, MonadIO m, IsIOStream a, IsWebsocketExtension b) 
=> a

stream: a IOStream connected to the WebSocket server

-> URI

uri: the URI of the connection

-> WebsocketConnectionType

type: the type of connection (client/side)

-> Maybe Text

origin: the Origin of the client

-> Maybe Text

protocol: the subprotocol in use

-> [b]

extensions: a List of WebsocketExtension objects

-> m WebsocketConnection

Returns: a new WebsocketConnection

Creates a WebsocketConnection on stream with the given active extensions. This should be called after completing the handshake to begin using the WebSocket protocol.

Since: 2.68

sendBinary

websocketConnectionSendBinary Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> Maybe ByteString

data: the message contents

-> m () 

Send a binary message to the peer. If length is 0, data may be Nothing.

The message is queued to be sent and will be sent when the main loop is run.

Since: 2.50

sendMessage

websocketConnectionSendMessage Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> WebsocketDataType

type: the type of message contents

-> Bytes

message: the message data as Bytes

-> m () 

Send a message of the given type to the peer. Note that this method, allows to send text messages containing Nothing characters.

The message is queued to be sent and will be sent when the main loop is run.

Since: 2.68

sendText

websocketConnectionSendText Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> Text

text: the message contents

-> m () 

Send a Nothing-terminated text (UTF-8) message to the peer. If you need to send text messages containing Nothing characters use websocketConnectionSendMessage instead.

The message is queued to be sent and will be sent when the main loop is run.

Since: 2.50

setKeepaliveInterval

websocketConnectionSetKeepaliveInterval Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> Word32

interval: the interval to send a ping message or 0 to disable it

-> m () 

Sets the interval in seconds on when to send a ping message which will serve as a keepalive message. If set to 0 the keepalive message is disabled.

Since: 2.58

setMaxIncomingPayloadSize

websocketConnectionSetMaxIncomingPayloadSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsWebsocketConnection a) 
=> a

self: the WebSocket

-> Word64

maxIncomingPayloadSize: the maximum payload size

-> m () 

Sets the maximum payload size allowed for incoming packets. It does not limit the outgoing packet size.

Since: 2.56

Properties

connectionType

The type of connection (client/server).

Since: 2.50

constructWebsocketConnectionConnectionType :: (IsWebsocketConnection o, MonadIO m) => WebsocketConnectionType -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “connection-type” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionConnectionType :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketConnectionType Source #

Get the value of the “connection-type” property. When overloading is enabled, this is equivalent to

get websocketConnection #connectionType

extensions

List of WebsocketExtension objects that are active in the connection.

Since: 2.68

constructWebsocketConnectionExtensions :: (IsWebsocketConnection o, MonadIO m) => Ptr () -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “extensions” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionExtensions :: (MonadIO m, IsWebsocketConnection o) => o -> m (Ptr ()) Source #

Get the value of the “extensions” property. When overloading is enabled, this is equivalent to

get websocketConnection #extensions

ioStream

The underlying IO stream the WebSocket is communicating over.

The input and output streams must be pollable streams.

Since: 2.50

constructWebsocketConnectionIoStream :: (IsWebsocketConnection o, MonadIO m, IsIOStream a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “io-stream” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionIoStream :: (MonadIO m, IsWebsocketConnection o) => o -> m IOStream Source #

Get the value of the “io-stream” property. When overloading is enabled, this is equivalent to

get websocketConnection #ioStream

keepaliveInterval

Interval in seconds on when to send a ping message which will serve as a keepalive message. If set to 0 the keepalive message is disabled.

Since: 2.58

constructWebsocketConnectionKeepaliveInterval :: (IsWebsocketConnection o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “keepalive-interval” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionKeepaliveInterval :: (MonadIO m, IsWebsocketConnection o) => o -> m Word32 Source #

Get the value of the “keepalive-interval” property. When overloading is enabled, this is equivalent to

get websocketConnection #keepaliveInterval

setWebsocketConnectionKeepaliveInterval :: (MonadIO m, IsWebsocketConnection o) => o -> Word32 -> m () Source #

Set the value of the “keepalive-interval” property. When overloading is enabled, this is equivalent to

set websocketConnection [ #keepaliveInterval := value ]

maxIncomingPayloadSize

The maximum payload size for incoming packets the protocol expects or 0 to not limit it.

Since: 2.56

constructWebsocketConnectionMaxIncomingPayloadSize :: (IsWebsocketConnection o, MonadIO m) => Word64 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “max-incoming-payload-size” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> m Word64 Source #

Get the value of the “max-incoming-payload-size” property. When overloading is enabled, this is equivalent to

get websocketConnection #maxIncomingPayloadSize

setWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> Word64 -> m () Source #

Set the value of the “max-incoming-payload-size” property. When overloading is enabled, this is equivalent to

set websocketConnection [ #maxIncomingPayloadSize := value ]

origin

The client's Origin.

Since: 2.50

constructWebsocketConnectionOrigin :: (IsWebsocketConnection o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “origin” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionOrigin :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe Text) Source #

Get the value of the “origin” property. When overloading is enabled, this is equivalent to

get websocketConnection #origin

protocol

The chosen protocol, or Nothing if a protocol was not agreed upon.

Since: 2.50

constructWebsocketConnectionProtocol :: (IsWebsocketConnection o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “protocol” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionProtocol :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe Text) Source #

Get the value of the “protocol” property. When overloading is enabled, this is equivalent to

get websocketConnection #protocol

state

The current state of the WebSocket.

Since: 2.50

getWebsocketConnectionState :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketState Source #

Get the value of the “state” property. When overloading is enabled, this is equivalent to

get websocketConnection #state

uri

The URI of the WebSocket.

For servers this represents the address of the WebSocket, and for clients it is the address connected to.

Since: 2.50

constructWebsocketConnectionUri :: (IsWebsocketConnection o, MonadIO m) => URI -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “uri” property. This is rarely needed directly, but it is used by new.

getWebsocketConnectionUri :: (MonadIO m, IsWebsocketConnection o) => o -> m URI Source #

Get the value of the “uri” property. When overloading is enabled, this is equivalent to

get websocketConnection #uri

Signals

closed

type C_WebsocketConnectionClosedCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type WebsocketConnectionClosedCallback = IO () Source #

Emitted when the connection has completely closed, either due to an orderly close from the peer, one initiated via websocketConnectionClose or a fatal error condition that caused a close.

This signal will be emitted once.

Since: 2.50

afterWebsocketConnectionClosed :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId Source #

Connect a signal handler for the closed signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after websocketConnection #closed callback

onWebsocketConnectionClosed :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId Source #

Connect a signal handler for the closed signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on websocketConnection #closed callback

closing

type C_WebsocketConnectionClosingCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type WebsocketConnectionClosingCallback = IO () Source #

This signal will be emitted during an orderly close.

Since: 2.50

afterWebsocketConnectionClosing :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId Source #

Connect a signal handler for the closing signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after websocketConnection #closing callback

onWebsocketConnectionClosing :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId Source #

Connect a signal handler for the closing signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on websocketConnection #closing callback

error

type C_WebsocketConnectionErrorCallback = Ptr () -> Ptr GError -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type WebsocketConnectionErrorCallback Source #

Arguments

 = GError

error: the error that occured

-> IO () 

Emitted when an error occurred on the WebSocket. This may be fired multiple times. Fatal errors will be followed by the closed signal being emitted.

Since: 2.50

afterWebsocketConnectionError :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId Source #

Connect a signal handler for the error signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after websocketConnection #error callback

onWebsocketConnectionError :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId Source #

Connect a signal handler for the error signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on websocketConnection #error callback

message

type C_WebsocketConnectionMessageCallback = Ptr () -> Int32 -> Ptr Bytes -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type WebsocketConnectionMessageCallback Source #

Arguments

 = Int32

type: the type of message contents

-> Bytes

message: the message data

-> IO () 

Emitted when we receive a message from the peer.

As a convenience, the message data will always be NUL-terminated, but the NUL byte will not be included in the length count.

Since: 2.50

afterWebsocketConnectionMessage :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId Source #

Connect a signal handler for the message signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after websocketConnection #message callback

onWebsocketConnectionMessage :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId Source #

Connect a signal handler for the message signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on websocketConnection #message callback

pong

type C_WebsocketConnectionPongCallback = Ptr () -> Ptr Bytes -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type WebsocketConnectionPongCallback Source #

Arguments

 = Bytes

message: the application data (if any)

-> IO () 

Emitted when we receive a Pong frame (solicited or unsolicited) from the peer.

As a convenience, the message data will always be NUL-terminated, but the NUL byte will not be included in the length count.

Since: 2.60

afterWebsocketConnectionPong :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionPongCallback -> m SignalHandlerId Source #

Connect a signal handler for the pong signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after websocketConnection #pong callback

onWebsocketConnectionPong :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionPongCallback -> m SignalHandlerId Source #

Connect a signal handler for the pong signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on websocketConnection #pong callback