billstclair/elm-websocket-framework/14.1.0

NOTE: the latest version is 15.0.0

WebSocketFramework.EncodeDecode

The EncodeDecode module handles translation of strings sent over the wire to and from your message types.

High-level functions

Your WebSocket subscription message handler will need to use decodeMessage, you will often use genericMessageDecoder, and, if you track statistics, you'll likely need the statistics encoder & decoder, but you'll rarely directly use the rest of the functions in this module.

decodeMessage : MessageDecoder message -> String -> Result String message

Use a MessageDecoder that you write to turn a string into a message.

DecoderPlist msg
-> DecoderPlist msg
-> ( ReqRsp, Plist )
-> Result String msg

Simplify the writing of MessageDecoder definitions.

Takes two plists mapping request names to decoders and response names to decoders.

Returns a MessageDecoder that uses them.

encodeMessage : MessageEncoder message -> message -> String

Use a MessageEncoder that you write to turn a message into a string.

messageDecoder : MessageDecoder message -> Decoder message

Create a Decoder for decodeMessage.

messageEncoder : MessageEncoder message -> message -> Value

Use a MessageEncoder that you write to turn a message into a Value.

Rarely used by anything but encodeMessage.

encodeStatistics : Statistics -> Value

Encode a Statistics record.

statisticsDecoder : Decoder Statistics

Decoder for the Statistics record.

Low-level functions

decodeRawMessage : String -> Result String RawMessage

Turn a string into a raw message.

rawMessageDecoder : Decoder RawMessage

The Decoder used by decodeRawMessage

rawMessageEncoder : RawMessage -> Value

Turn a raw message into a Value.

decodePlist : Decoder message -> Plist -> Result String message

Decode a list of key/value pairs into a message.