box-socket-0.5.1.0: Box websockets
Safe HaskellSafe-Inferred
LanguageGHC2021

Box.Websocket

Description

Websocket components built with Boxes.

Synopsis

Documentation

data SocketConfig Source #

Socket configuration

>>> defaultSocketConfig
SocketConfig {host = "127.0.0.1", port = 9160, path = "/"}

Constructors

SocketConfig 

Fields

Instances

Instances details
Generic SocketConfig Source # 
Instance details

Defined in Box.Websocket

Associated Types

type Rep SocketConfig :: Type -> Type #

Show SocketConfig Source # 
Instance details

Defined in Box.Websocket

Eq SocketConfig Source # 
Instance details

Defined in Box.Websocket

type Rep SocketConfig Source # 
Instance details

Defined in Box.Websocket

type Rep SocketConfig = D1 ('MetaData "SocketConfig" "Box.Websocket" "box-socket-0.5.1.0-HZSvScoEvBQ2CZcs9ZHRQi" 'False) (C1 ('MetaCons "SocketConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "host") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "port") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "path") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))))

connect :: SocketConfig -> Codensity IO Connection Source #

connect an action (ie a client)

serve :: SocketConfig -> Codensity IO Connection Source #

serve an action (ie a server)

serverApp :: Box IO Text Text -> PendingConnection -> IO () Source #

Attach a box to a PendingConnection in wai-style.

receiver :: WebSocketsData a => Committer IO a -> Connection -> IO () Source #

Commit received messages, finalising on receiving a CloseRequest

receiver_ :: (WebSocketsData a, Show a) => Committer IO a -> Committer IO Text -> Connection -> IO () Source #

Commit received messages, finalising on receiving a CloseRequest, with event logging.

sender :: WebSocketsData a => Emitter IO a -> Connection -> IO SocketStatus Source #

Send emitted messages, returning whether the socket remained open (the Emitter ran out of emits) or closed (a CloseRequest was received).

sender_ :: (WebSocketsData a, Show a) => Emitter IO a -> Committer IO Text -> Connection -> IO SocketStatus Source #

Send emitted messages, returning whether the socket remained open (the Emitter ran out of emits) or closed (a CloseRequest was received). With event logging.

duplex :: WebSocketsData a => PostSend -> Box IO a a -> Connection -> IO () Source #

A two-way connection. Closes if it receives a CloseRequest exception, or if PostSend is CloseAfter.

duplex_ :: (WebSocketsData a, Show a) => PostSend -> Committer IO Text -> Box IO a a -> Connection -> IO () Source #

A two-way connection. Closes if it receives a CloseRequest exception, or if PostSend is CloseAfter. With event logging.

clientBox :: WebSocketsData a => SocketConfig -> PostSend -> Box IO a a -> IO () Source #

A Box action for a client.

serverBox :: WebSocketsData a => SocketConfig -> PostSend -> Box IO a a -> IO () Source #

A Box action for a server.

responseServer :: WebSocketsData a => SocketConfig -> (a -> Maybe a) -> IO () Source #

A receiver that applies a response function to received messages.