Copyright | (c) 2016 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | experimental |
Portability | OverloadedStrings |
Safe Haskell | None |
Language | Haskell2010 |
Pusher network client. This is NOT considered to form part of the public API of this library.
- pusherClient :: Pusher -> ((Connection -> IO ()) -> IO ()) -> IO ()
- client :: Pusher -> Connection -> IO ()
- awaitCommandOrClose :: Pusher -> TVar (Maybe Word16) -> IO (Either Word16 PusherCommand)
- handleCommandOrClose :: Pusher -> Connection -> Either Word16 PusherCommand -> IO ()
- handleCommand :: Pusher -> Connection -> PusherCommand -> IO ()
- throwCloseException :: Word16 -> IO a
- pingThread :: Pusher -> Connection -> TVar (Maybe Word16) -> IO ()
- handleThread :: Pusher -> Connection -> TVar (Maybe Word16) -> IO ()
- reconnectImmediately :: Maybe Word16
- changeConnectionState :: Pusher -> ConnectionState -> IO ()
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.