Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
GI.Soup.Objects.WebsocketConnection
Description
A class representing a WebSocket connection.
- newtype WebsocketConnection = WebsocketConnection (ManagedPtr WebsocketConnection)
- class GObject o => IsWebsocketConnection o
- toWebsocketConnection :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketConnection
- noWebsocketConnection :: Maybe WebsocketConnection
- websocketConnectionClose :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> Word16 -> Maybe Text -> m ()
- websocketConnectionGetCloseCode :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m Word16
- websocketConnectionGetCloseData :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m Text
- websocketConnectionGetConnectionType :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m WebsocketConnectionType
- websocketConnectionGetIoStream :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m IOStream
- websocketConnectionGetKeepaliveInterval :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m Word32
- websocketConnectionGetMaxIncomingPayloadSize :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m Word64
- websocketConnectionGetOrigin :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m (Maybe Text)
- websocketConnectionGetProtocol :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m (Maybe Text)
- websocketConnectionGetState :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m WebsocketState
- websocketConnectionGetUri :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> m URI
- websocketConnectionNew :: (HasCallStack, MonadIO m, IsIOStream a) => a -> URI -> WebsocketConnectionType -> Maybe Text -> Maybe Text -> m WebsocketConnection
- websocketConnectionSendBinary :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> ByteString -> m ()
- websocketConnectionSendText :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> Text -> m ()
- websocketConnectionSetKeepaliveInterval :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> Word32 -> m ()
- websocketConnectionSetMaxIncomingPayloadSize :: (HasCallStack, MonadIO m, IsWebsocketConnection a) => a -> Word64 -> m ()
- constructWebsocketConnectionConnectionType :: IsWebsocketConnection o => WebsocketConnectionType -> IO (GValueConstruct o)
- getWebsocketConnectionConnectionType :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketConnectionType
- constructWebsocketConnectionIoStream :: (IsWebsocketConnection o, IsIOStream a) => a -> IO (GValueConstruct o)
- getWebsocketConnectionIoStream :: (MonadIO m, IsWebsocketConnection o) => o -> m IOStream
- constructWebsocketConnectionKeepaliveInterval :: IsWebsocketConnection o => Word32 -> IO (GValueConstruct o)
- getWebsocketConnectionKeepaliveInterval :: (MonadIO m, IsWebsocketConnection o) => o -> m Word32
- setWebsocketConnectionKeepaliveInterval :: (MonadIO m, IsWebsocketConnection o) => o -> Word32 -> m ()
- constructWebsocketConnectionMaxIncomingPayloadSize :: IsWebsocketConnection o => Word64 -> IO (GValueConstruct o)
- getWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> m Word64
- setWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> Word64 -> m ()
- constructWebsocketConnectionOrigin :: IsWebsocketConnection o => Text -> IO (GValueConstruct o)
- getWebsocketConnectionOrigin :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe Text)
- constructWebsocketConnectionProtocol :: IsWebsocketConnection o => Text -> IO (GValueConstruct o)
- getWebsocketConnectionProtocol :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe Text)
- getWebsocketConnectionState :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketState
- constructWebsocketConnectionUri :: IsWebsocketConnection o => URI -> IO (GValueConstruct o)
- getWebsocketConnectionUri :: (MonadIO m, IsWebsocketConnection o) => o -> m URI
- type C_WebsocketConnectionClosedCallback = Ptr () -> Ptr () -> IO ()
- type WebsocketConnectionClosedCallback = IO ()
- afterWebsocketConnectionClosed :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId
- genClosure_WebsocketConnectionClosed :: WebsocketConnectionClosedCallback -> IO Closure
- mk_WebsocketConnectionClosedCallback :: C_WebsocketConnectionClosedCallback -> IO (FunPtr C_WebsocketConnectionClosedCallback)
- noWebsocketConnectionClosedCallback :: Maybe WebsocketConnectionClosedCallback
- onWebsocketConnectionClosed :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId
- wrap_WebsocketConnectionClosedCallback :: WebsocketConnectionClosedCallback -> Ptr () -> Ptr () -> IO ()
- type C_WebsocketConnectionClosingCallback = Ptr () -> Ptr () -> IO ()
- type WebsocketConnectionClosingCallback = IO ()
- afterWebsocketConnectionClosing :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId
- genClosure_WebsocketConnectionClosing :: WebsocketConnectionClosingCallback -> IO Closure
- mk_WebsocketConnectionClosingCallback :: C_WebsocketConnectionClosingCallback -> IO (FunPtr C_WebsocketConnectionClosingCallback)
- noWebsocketConnectionClosingCallback :: Maybe WebsocketConnectionClosingCallback
- onWebsocketConnectionClosing :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId
- wrap_WebsocketConnectionClosingCallback :: WebsocketConnectionClosingCallback -> Ptr () -> Ptr () -> IO ()
- type C_WebsocketConnectionErrorCallback = Ptr () -> Ptr GError -> Ptr () -> IO ()
- type WebsocketConnectionErrorCallback = GError -> IO ()
- afterWebsocketConnectionError :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId
- genClosure_WebsocketConnectionError :: WebsocketConnectionErrorCallback -> IO Closure
- mk_WebsocketConnectionErrorCallback :: C_WebsocketConnectionErrorCallback -> IO (FunPtr C_WebsocketConnectionErrorCallback)
- noWebsocketConnectionErrorCallback :: Maybe WebsocketConnectionErrorCallback
- onWebsocketConnectionError :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId
- wrap_WebsocketConnectionErrorCallback :: WebsocketConnectionErrorCallback -> Ptr () -> Ptr GError -> Ptr () -> IO ()
- type C_WebsocketConnectionMessageCallback = Ptr () -> Int32 -> Ptr Bytes -> Ptr () -> IO ()
- type WebsocketConnectionMessageCallback = Int32 -> Bytes -> IO ()
- afterWebsocketConnectionMessage :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId
- genClosure_WebsocketConnectionMessage :: WebsocketConnectionMessageCallback -> IO Closure
- mk_WebsocketConnectionMessageCallback :: C_WebsocketConnectionMessageCallback -> IO (FunPtr C_WebsocketConnectionMessageCallback)
- noWebsocketConnectionMessageCallback :: Maybe WebsocketConnectionMessageCallback
- onWebsocketConnectionMessage :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId
- wrap_WebsocketConnectionMessageCallback :: WebsocketConnectionMessageCallback -> Ptr () -> Int32 -> Ptr Bytes -> Ptr () -> IO ()
Exported types
newtype WebsocketConnection Source #
Constructors
WebsocketConnection (ManagedPtr WebsocketConnection) |
class GObject o => IsWebsocketConnection o Source #
toWebsocketConnection :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketConnection Source #
Methods
close
websocketConnectionClose Source #
Arguments
:: (HasCallStack, MonadIO m, IsWebsocketConnection a) | |
=> a |
|
-> Word16 |
|
-> Maybe Text |
|
-> m () |
Close the connection in an orderly fashion.
Note that until the WebsocketConnection
::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.
Note that the data
must be UTF-8 valid.
Since: 2.50
getCloseCode
websocketConnectionGetCloseCode Source #
Arguments
:: (HasCallStack, MonadIO m, IsWebsocketConnection a) | |
=> a |
|
-> 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 |
|
-> m Text | Returns: the close data or |
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 |
|
-> m WebsocketConnectionType | Returns: the connection type |
Get the connection type (client/server) of the connection.
Since: 2.50
getIoStream
websocketConnectionGetIoStream Source #
Arguments
:: (HasCallStack, MonadIO m, IsWebsocketConnection a) | |
=> a |
|
-> 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 |
|
-> 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 |
|
-> 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 |
|
-> m (Maybe Text) | Returns: the origin, or |
Get the origin of the WebSocket.
Since: 2.50
getProtocol
websocketConnectionGetProtocol Source #
Arguments
:: (HasCallStack, MonadIO m, IsWebsocketConnection a) | |
=> a |
|
-> m (Maybe Text) | Returns: the chosen protocol, or |
Get the protocol chosen via negotiation with the peer.
Since: 2.50
getState
websocketConnectionGetState Source #
Arguments
:: (HasCallStack, MonadIO m, IsWebsocketConnection a) | |
=> a |
|
-> 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 |
|
-> 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 |
|
-> URI |
|
-> WebsocketConnectionType |
|
-> Maybe Text |
|
-> Maybe Text |
|
-> m WebsocketConnection | Returns: a new |
Creates a WebsocketConnection
on stream
. This should be
called after completing the handshake to begin using the WebSocket
protocol.
Since: 2.50
sendBinary
websocketConnectionSendBinary Source #
Arguments
:: (HasCallStack, MonadIO m, IsWebsocketConnection a) | |
=> a |
|
-> ByteString |
|
-> m () |
Send a binary message to the peer.
The message is queued to be sent and will be sent when the main loop is run.
Since: 2.50
sendText
websocketConnectionSendText Source #
Arguments
:: (HasCallStack, MonadIO m, IsWebsocketConnection a) | |
=> a |
|
-> Text |
|
-> m () |
Send a text (UTF-8) message to the peer.
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 |
|
-> Word32 |
|
-> 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 |
|
-> Word64 |
|
-> m () |
Sets the maximum payload size allowed for incoming packets. It does not limit the outgoing packet size.
Since: 2.56
Properties
connectionType
constructWebsocketConnectionConnectionType :: IsWebsocketConnection o => WebsocketConnectionType -> IO (GValueConstruct o) Source #
getWebsocketConnectionConnectionType :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketConnectionType Source #
ioStream
constructWebsocketConnectionIoStream :: (IsWebsocketConnection o, IsIOStream a) => a -> IO (GValueConstruct o) Source #
getWebsocketConnectionIoStream :: (MonadIO m, IsWebsocketConnection o) => o -> m IOStream Source #
keepaliveInterval
constructWebsocketConnectionKeepaliveInterval :: IsWebsocketConnection o => Word32 -> IO (GValueConstruct o) Source #
getWebsocketConnectionKeepaliveInterval :: (MonadIO m, IsWebsocketConnection o) => o -> m Word32 Source #
setWebsocketConnectionKeepaliveInterval :: (MonadIO m, IsWebsocketConnection o) => o -> Word32 -> m () Source #
maxIncomingPayloadSize
constructWebsocketConnectionMaxIncomingPayloadSize :: IsWebsocketConnection o => Word64 -> IO (GValueConstruct o) Source #
getWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> m Word64 Source #
setWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> Word64 -> m () Source #
origin
constructWebsocketConnectionOrigin :: IsWebsocketConnection o => Text -> IO (GValueConstruct o) Source #
getWebsocketConnectionOrigin :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe Text) Source #
protocol
constructWebsocketConnectionProtocol :: IsWebsocketConnection o => Text -> IO (GValueConstruct o) Source #
getWebsocketConnectionProtocol :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe Text) Source #
state
getWebsocketConnectionState :: (MonadIO m, IsWebsocketConnection o) => o -> m WebsocketState Source #
uri
constructWebsocketConnectionUri :: IsWebsocketConnection o => URI -> IO (GValueConstruct o) Source #
getWebsocketConnectionUri :: (MonadIO m, IsWebsocketConnection o) => o -> m URI Source #
Signals
closed
type WebsocketConnectionClosedCallback = IO () Source #
afterWebsocketConnectionClosed :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId Source #
mk_WebsocketConnectionClosedCallback :: C_WebsocketConnectionClosedCallback -> IO (FunPtr C_WebsocketConnectionClosedCallback) Source #
onWebsocketConnectionClosed :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId Source #
wrap_WebsocketConnectionClosedCallback :: WebsocketConnectionClosedCallback -> Ptr () -> Ptr () -> IO () Source #
closing
type WebsocketConnectionClosingCallback = IO () Source #
afterWebsocketConnectionClosing :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId Source #
mk_WebsocketConnectionClosingCallback :: C_WebsocketConnectionClosingCallback -> IO (FunPtr C_WebsocketConnectionClosingCallback) Source #
onWebsocketConnectionClosing :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId Source #
wrap_WebsocketConnectionClosingCallback :: WebsocketConnectionClosingCallback -> Ptr () -> Ptr () -> IO () Source #
error
type WebsocketConnectionErrorCallback = GError -> IO () Source #
afterWebsocketConnectionError :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId Source #
mk_WebsocketConnectionErrorCallback :: C_WebsocketConnectionErrorCallback -> IO (FunPtr C_WebsocketConnectionErrorCallback) Source #
onWebsocketConnectionError :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId Source #
wrap_WebsocketConnectionErrorCallback :: WebsocketConnectionErrorCallback -> Ptr () -> Ptr GError -> Ptr () -> IO () Source #
message
type C_WebsocketConnectionMessageCallback = Ptr () -> Int32 -> Ptr Bytes -> Ptr () -> IO () Source #
afterWebsocketConnectionMessage :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId Source #
mk_WebsocketConnectionMessageCallback :: C_WebsocketConnectionMessageCallback -> IO (FunPtr C_WebsocketConnectionMessageCallback) Source #
onWebsocketConnectionMessage :: (IsWebsocketConnection a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId Source #
wrap_WebsocketConnectionMessageCallback :: WebsocketConnectionMessageCallback -> Ptr () -> Int32 -> Ptr Bytes -> Ptr () -> IO () Source #