Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Engine = Engine {}
- start :: (Engine -> IO ()) -> Application -> Application
- addListener :: Engine -> (Value -> IO ()) -> IO ThreadId
- listen :: Engine -> IO Value
- readEventChan :: Engine -> STM (Value, UTCTime)
- type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
Web Services
An Engine
is a handle to a specific JavaScript engine
start :: (Engine -> IO ()) -> Application -> Application Source #
This accepts WebSocket requests, calls the callback with
an Engine
that can be used to access JavaScript.
addListener :: Engine -> (Value -> IO ()) -> IO ThreadId Source #
Add a listener for events. There can be many. non-blocking.
From JavaScript, you can call event(..) to send values to this listener. Any valid JSON value can be sent.
listen :: Engine -> IO Value Source #
listen
for the next event. blocking.
From JavaScript, you can call event(..) to send values to this listener. Any valid JSON value can be sent.
readEventChan :: Engine -> STM (Value, UTCTime) Source #
readEventChan
uses STM to read the next event.
From JavaScript, you can call event(..) to send values to this channel. Any valid JSON value can be sent.
type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived #
The WAI application.
Note that, since WAI 3.0, this type is structured in continuation passing
style to allow for proper safe resource handling. This was handled in the
past via other means (e.g., ResourceT
). As a demonstration:
app :: Application app req respond = bracket_ (putStrLn "Allocating scarce resource") (putStrLn "Cleaning up") (respond $ responseLBS status200 [] "Hello World")