| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.API.WSServer
Synopsis
- data WsCodec tx = WsCodec {
- sendOutput :: TimedServerOutput tx -> IO ()
- sendClientMessage :: ClientMessage tx -> IO ()
- sendGreetings :: Greetings tx -> IO ()
- sendInvalidInput :: InvalidInput -> IO ()
- decodeInput :: ByteString -> Either String (ClientInput tx)
- describeInput :: ByteString -> Text
- mkWsCodec :: IsChainState tx => ServerOutputConfig -> Connection -> WsCodec tx
- wsApp :: forall tx. IsChainState tx => Environment -> Party -> Tracer IO APIServerLog -> Chain tx IO -> ConduitT () (TimedServerOutput tx) (ResourceT IO) () -> (ClientInput tx -> IO ()) -> Projection STM (StateChanged tx) (NodeState tx) -> Projection STM (StateChanged tx) NetworkInfo -> TChan (Either (TimedServerOutput tx) (ClientMessage tx)) -> ServerOutputFilter tx -> PendingConnection -> IO ()
- queryParamsOf :: ByteString -> Query
- mkServerOutputConfig :: Query -> ServerOutputConfig
- decideOnEncoding :: Query -> ApiEncoding
- decideOnUTxODisplay :: Query -> WithUTxO
- decideOnAddressDisplay :: Query -> WithAddressedTx
- shouldServeHistory :: Query -> Bool
Documentation
Per-connection codec: resolves the negotiated wire encoding and the snapshot-utxo display policy once, so message handling needs no dispatch.
Constructors
| WsCodec | |
Fields
| |
mkWsCodec :: IsChainState tx => ServerOutputConfig -> Connection -> WsCodec tx Source #
Resolve the negotiated encoding into a WsCodec. This is the only place
deciding how messages go onto (and come off) the wire: JSON as text frames,
CBOR as binary frames.
NOTE: Inputs are decoded per the negotiated encoding, never the frame type: some JSON clients (e.g. the TUI) send binary frames containing JSON.
Arguments
| :: forall tx. IsChainState tx | |
| => Environment | |
| -> Party | |
| -> Tracer IO APIServerLog | |
| -> Chain tx IO | |
| -> ConduitT () (TimedServerOutput tx) (ResourceT IO) () | |
| -> (ClientInput tx -> IO ()) | |
| -> Projection STM (StateChanged tx) (NodeState tx) | Read model to enhance |
| -> Projection STM (StateChanged tx) NetworkInfo | Read model to enhance |
| -> TChan (Either (TimedServerOutput tx) (ClientMessage tx)) | |
| -> ServerOutputFilter tx | |
| -> PendingConnection | |
| -> IO () |
queryParamsOf :: ByteString -> Query Source #
The query parameters of a websocket connection request path.
NOTE: a malformed query string yields no parameters here, and hence the default output config. modern-uri (used here previously) raised a parse exception during connection setup instead.
mkServerOutputConfig :: Query -> ServerOutputConfig Source #
Decide what a client wants to see, from the query string of its connection.
decideOnEncoding :: Query -> ApiEncoding Source #
decideOnUTxODisplay :: Query -> WithUTxO Source #
decideOnAddressDisplay :: Query -> WithAddressedTx Source #
shouldServeHistory :: Query -> Bool Source #