Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type WebSocketsT = ReaderT Connection
- webSockets :: (MonadUnliftIO m, MonadHandler m) => WebSocketsT m () -> m ()
- webSocketsWith :: (MonadUnliftIO m, MonadHandler m) => (RequestHead -> m (Maybe AcceptRequest)) -> WebSocketsT m () -> m ()
- webSocketsOptions :: (MonadUnliftIO m, MonadHandler m) => ConnectionOptions -> WebSocketsT m () -> m ()
- webSocketsOptionsWith :: (MonadUnliftIO m, MonadHandler m) => ConnectionOptions -> (RequestHead -> m (Maybe AcceptRequest)) -> WebSocketsT m () -> m ()
- receiveData :: (MonadIO m, MonadReader Connection m, WebSocketsData a) => m a
- receiveDataE :: (MonadIO m, MonadReader Connection m, WebSocketsData a) => m (Either SomeException a)
- receiveDataMessageE :: (MonadIO m, MonadReader Connection m) => m (Either SomeException DataMessage)
- sendPing :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m ()
- sendPingE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ())
- sendClose :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m ()
- sendCloseE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ())
- sendTextData :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m ()
- sendTextDataE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ())
- sendBinaryData :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m ()
- sendBinaryDataE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ())
- sendDataMessageE :: (MonadIO m, MonadReader Connection m) => DataMessage -> m (Either SomeException ())
- sourceWS :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => ConduitT i a m ()
- sinkWSText :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => ConduitT a o m ()
- sinkWSBinary :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => ConduitT a o m ()
- race :: MonadUnliftIO m => m a -> m b -> m (Either a b)
- race_ :: MonadUnliftIO m => m a -> m b -> m ()
- concurrently :: MonadUnliftIO m => m a -> m b -> m (a, b)
- concurrently_ :: MonadUnliftIO m => m a -> m b -> m ()
- defaultConnectionOptions :: ConnectionOptions
- data ConnectionOptions = ConnectionOptions {}
Core API
type WebSocketsT = ReaderT Connection Source #
A transformer for a WebSockets handler.
Since 0.1.0
webSockets :: (MonadUnliftIO m, MonadHandler m) => WebSocketsT m () -> m () Source #
Attempt to run a WebSockets handler. This function first checks if the client initiated a WebSockets connection and, if so, runs the provided application, short-circuiting the rest of your handler. If the client did not request a WebSockets connection, the rest of your handler will be called instead.
Since 0.1.0
:: (MonadUnliftIO m, MonadHandler m) | |
=> (RequestHead -> m (Maybe AcceptRequest)) | A Nothing indicates that the websocket upgrade request should not happen
and instead the rest of the handler will be called instead. This allows
you to use |
-> WebSocketsT m () | |
-> m () |
Varient of webSockets
which allows you to specify the AcceptRequest
setttings when upgrading to a websocket connection.
Since 0.2.4
webSocketsOptions :: (MonadUnliftIO m, MonadHandler m) => ConnectionOptions -> WebSocketsT m () -> m () Source #
Varient of webSockets
which allows you to specify
the WS.ConnectionOptions setttings when upgrading to a websocket connection.
Since 0.2.5
webSocketsOptionsWith Source #
:: (MonadUnliftIO m, MonadHandler m) | |
=> ConnectionOptions | Custom websockets options |
-> (RequestHead -> m (Maybe AcceptRequest)) | A Nothing indicates that the websocket upgrade request should not happen
and instead the rest of the handler will be called instead. This allows
you to use |
-> WebSocketsT m () | |
-> m () |
Varient of webSockets
which allows you to specify both
the WS.ConnectionOptions and the AcceptRequest
setttings when upgrading to a websocket connection.
Since 0.2.5
receiveData :: (MonadIO m, MonadReader Connection m, WebSocketsData a) => m a Source #
Receive a piece of data from the client.
Since 0.1.0
receiveDataE :: (MonadIO m, MonadReader Connection m, WebSocketsData a) => m (Either SomeException a) Source #
Receive a piece of data from the client. Capture SomeException as the result or operation Since 0.2.2
receiveDataMessageE :: (MonadIO m, MonadReader Connection m) => m (Either SomeException DataMessage) Source #
Receive an application message. Capture SomeException as the result or operation Since 0.2.3
sendPing :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m () Source #
Send a ping message to the client.
Since 0.2.2
sendPingE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ()) Source #
Send a ping message to the client. Capture SomeException as the result of operation Since 0.2.2
sendClose :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m () Source #
Send a close request to the client.
Since 0.2.2
sendCloseE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ()) Source #
Send a close request to the client. Capture SomeException as the result of operation Since 0.2.2
sendTextData :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m () Source #
Send a textual message to the client.
Since 0.1.0
sendTextDataE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ()) Source #
Send a textual message to the client. Capture SomeException as the result or operation and can be used like `either handle_exception return =<< sendTextDataE (Welcome :: Text)` Since 0.2.2
sendBinaryData :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m () Source #
Send a binary message to the client.
Since 0.1.0
sendBinaryDataE :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => a -> m (Either SomeException ()) Source #
Send a binary message to the client. Capture SomeException as the result of operation Since 0.2.2
sendDataMessageE :: (MonadIO m, MonadReader Connection m) => DataMessage -> m (Either SomeException ()) Source #
Send a DataMessage to the client. Capture SomeException as the result of operation Since 0.2.3
Conduit API
sourceWS :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => ConduitT i a m () Source #
A Source
of WebSockets data from the user.
Since 0.1.0
sinkWSText :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => ConduitT a o m () Source #
A Sink
for sending textual data to the user.
Since 0.1.0
sinkWSBinary :: (MonadIO m, WebSocketsData a, MonadReader Connection m) => ConduitT a o m () Source #
A Sink
for sending binary data to the user.
Since 0.1.0
Async helpers
race :: MonadUnliftIO m => m a -> m b -> m (Either a b) #
Unlifted race
.
Since: unliftio-0.1.0.0
race_ :: MonadUnliftIO m => m a -> m b -> m () #
Unlifted race_
.
Since: unliftio-0.1.0.0
concurrently :: MonadUnliftIO m => m a -> m b -> m (a, b) #
Unlifted concurrently
.
Since: unliftio-0.1.0.0
concurrently_ :: MonadUnliftIO m => m a -> m b -> m () #
Unlifted concurrently_
.
Since: unliftio-0.1.0.0
Re-exports from websockets
defaultConnectionOptions :: ConnectionOptions #
The default connection options:
- Nothing happens when a pong is received.
- Compression is disabled.
- Lenient unicode decoding.
data ConnectionOptions #
Set options for a Connection
. Please do not use this constructor
directly, but rather use defaultConnectionOptions
and then set the fields
you want, e.g.:
myOptions = defaultConnectionOptions {connectionStrictUnicode = True}
This way your code does not break if the library introduces new fields.
ConnectionOptions | |
|