front-0.0.0.3: A reactive frontend web framework

Safe HaskellNone
LanguageHaskell2010

Web.Front.Broadcast

Synopsis

Documentation

interact :: (CommandHandler cache model message, Data message, Data message2) => Connection -> TChan (Out (Action message)) -> TChan (Out message2) -> cache model -> ClientId -> IO () Source #

The common way how to use websocket Connection obtained from Handler via Conduit. interact starts two concurrent processes. First one is responsible for reading data from stream, decoding JSON message, executing custom business logic implemented by user and pushing the produced outgoing message to TChan. The second process is constantly reading from TChan, encoding the given message and pushing it to all subscribers.

class Data cmd => CommandHandler cache model cmd where Source #

CommandHandler class contains all business logic, i.e. how to change the given state ('cache model'), synchronize state for all online sessions and produce outgoing message with the Action. Action contains ClientId to separate different sessions, ExecuteStrategy to tell the Client how to handle incoming message.

Methods

onCommand :: Value -> cache model -> ClientId -> IO (Out (Action cmd)) Source #