Copyright | (c) digitally induced GmbH 2020 |
---|---|
Safe Haskell | None |
Synopsis
- class WSApp state where
- initialState :: state
- run :: IO ()
- onPing :: IO ()
- onClose :: IO ()
- connectionOptions :: ConnectionOptions
- startWSApp :: (WSApp state, ?applicationContext :: ApplicationContext, ?requestContext :: RequestContext, ?context :: ControllerContext, ?modelContext :: ModelContext) => Connection -> IO ()
- setState :: (?state :: IORef state) => state -> IO ()
- getState :: (?state :: IORef state) => IO state
- receiveData :: (?connection :: Connection, WebSocketsData a) => IO a
- receiveDataMessage :: (?connection :: Connection) => IO DataMessage
- sendTextData :: (?connection :: Connection, WebSocketsData text) => text -> IO ()
- sendJSON :: (?connection :: Connection, ToJSON value) => value -> IO ()
Documentation
class WSApp state where Source #
initialState :: state Source #
connectionOptions :: ConnectionOptions Source #
Provide WebSocket Connection Options
See All Config Options Here https://hackage.haskell.org/package/websockets/docs/Network-WebSockets-Connection.html#t:ConnectionOptions
Example: Enable default permessage-deflate compression
connectionOptions = WebSocket.defaultConnectionOptions { WebSocket.connectionCompressionOptions = WebSocket.PermessageDeflateCompression WebSocket.defaultPermessageDeflate }
Instances
WSApp AutoRefreshWSApp Source # | |
Defined in IHP.AutoRefresh | |
(ToField (PrimaryKey (GetTableName CurrentUserRecord)), Show (PrimaryKey (GetTableName CurrentUserRecord)), HasNewSessionUrl CurrentUserRecord, Typeable CurrentUserRecord, HasField "id" CurrentUserRecord (Id' (GetTableName CurrentUserRecord))) => WSApp DataSyncController Source # | |
Defined in IHP.DataSync.Controller |
startWSApp :: (WSApp state, ?applicationContext :: ApplicationContext, ?requestContext :: RequestContext, ?context :: ControllerContext, ?modelContext :: ModelContext) => Connection -> IO () Source #
receiveData :: (?connection :: Connection, WebSocketsData a) => IO a Source #
receiveDataMessage :: (?connection :: Connection) => IO DataMessage Source #
sendTextData :: (?connection :: Connection, WebSocketsData text) => text -> IO () Source #
sendJSON :: (?connection :: Connection, ToJSON value) => value -> IO () Source #
Json encode a payload and send it over the websocket wire
Example:
message <- Aeson.decode <$> receiveData @LByteString case message of Just decodedMessage -> handleMessage decodedMessage Nothing -> sendJSON FailedToDecodeMessageError
Orphan instances
WebSocketsData UUID Source # | |
fromDataMessage :: DataMessage -> UUID fromLazyByteString :: ByteString -> UUID toLazyByteString :: UUID -> ByteString |