Simple interfaces for getting started with Websockets in Elm
Other modules are exposed for advanced usage.
withPorts : { command : CommandPort msg, event : EventPort msg } -> Methods msg
Helper to wrap your Ports
Json.Encode.Value -> Platform.Cmd.Cmd msg
Port to send Commands to the Websocket
(Json.Encode.Value -> msg) -> Platform.Sub.Sub msg
Port for subscribing to income events
{ open : String -> String -> List ( String
, Maybe String ) -> Platform.Cmd.Cmd msg
, close : String -> Platform.Cmd.Cmd msg
, send : String -> Json.Encode.Value -> Platform.Cmd.Cmd msg
, onEvent : EventHandlers msg -> Platform.Sub.Sub msg
}
Methods for using your sockets
{ onOpened : WebsocketOpened -> msg
, onClosed : WebsocketClosed -> msg
, onError : WebsocketError -> msg
, onMessage : WebsocketMessage -> msg
, onDecodeError : String -> msg
}
Event handlers for subscriptions
{ name : Event.Name
, meta : Meta
}
Record data when a socket is Opened
{ name : Event.Name
, meta : Meta
, data : String
}
Record data when a socket is Message
{ name : Event.Name
, meta : Meta
, reason : String
}
Record data when a socket is Closed
{ name : Event.Name
, meta : Meta
, error : Maybe String
}
Record data when a socket is Error