pusher-ws-0.1.1.0: Implementation of the Pusher WebSocket protocol

Copyright(c) 2016 Michael Walker
LicenseMIT
MaintainerMichael Walker <mike@barrucadu.co.uk>
Stabilityexperimental
PortabilityOverloadedStrings
Safe HaskellNone
LanguageHaskell2010

Network.Pusher.WebSockets.Internal.Client

Description

Pusher network client. This is NOT considered to form part of the public API of this library.

Synopsis

Documentation

pusherClient :: Pusher -> ((Connection -> IO ()) -> IO ()) -> IO () Source #

Client thread: connect to Pusher and process commands, reconnecting automatically, until finally told to terminate.

Does not automatically fork.

client :: Pusher -> Connection -> IO () Source #

Fork off event handling and pinging threads, subscribe to channels, and loop processing commands until terminated.

awaitCommandOrClose :: Pusher -> TVar (Maybe Word16) -> IO (Either Word16 PusherCommand) Source #

Wait for a command or close signal.

handleCommandOrClose :: Pusher -> Connection -> Either Word16 PusherCommand -> IO () Source #

Handle a command or close signal. Throws an exception on disconnect: TerminatePusher if the connection should not be re-established, and ConnectionClosed if it should be.

handleCommand :: Pusher -> Connection -> PusherCommand -> IO () Source #

Handle a command.

throwCloseException :: Word16 -> IO a Source #

Throw the appropriate exception for a close code.

pingThread :: Pusher -> Connection -> TVar (Maybe Word16) -> IO () Source #

Send a ping every time the timeout elapses. If the connection closes the reconnectImmediately close code is written to the TVar.

handleThread :: Pusher -> Connection -> TVar (Maybe Word16) -> IO () Source #

Receive and handle events until the connection is closed, at which point the close code is written to the provided TVar.

reconnectImmediately :: Maybe Word16 Source #

Just 4200 = generic reconnect immediately

changeConnectionState :: Pusher -> ConnectionState -> IO () Source #

Set the connection state and send a state change event if necessary.