{ websocketConnected : (Basics.Int -> FrameworkMsg msg) -> Platform.Sub.Sub (FrameworkMsg msg)
, websocketIn : (String -> FrameworkMsg msg) -> Platform.Sub.Sub (FrameworkMsg msg)
}
Hook up ports to use websockets for passing serverMsg and clientMsg
{ updateFromServer : serverMsg -> model -> ( model
, Platform.Cmd.Cmd msg )
, clientMsgEncoder : clientMsg -> Json.Encode.Value
, serverMsgDecoder : Json.Decode.Decoder serverMsg
, errorDecoder : Json.Decode.Decoder x
}
A set of required protocols.
- `updateFromServer` is called when `serverMsg` is received via websocket
- `clientMsgEncoder` encodes outgoing `clientMsg`, e.g. via `sendToServer`
- `serverMsgDecoder` decodes replies from Server
- `errorDecoder` decodes error replies from Server
element : { element : { init : flags -> ( model, Platform.Cmd.Cmd msg ), view : model -> Html msg, update : msg -> model -> ( model, Platform.Cmd.Cmd msg ), subscriptions : model -> Platform.Sub.Sub msg }, ports : Ports msg, protocol : Protocol serverMsg clientMsg model msg x } -> { element : Platform.Program flags model (FrameworkMsg msg), sendToServer : clientMsg -> Platform.Task Http.Error (Result x serverMsg) }
Returns a Browser.element
to use as main
in your client app
and a sendToServer
function to send clientMsg
with
document : { document : { init : flags -> ( model, Platform.Cmd.Cmd msg ), view : model -> Browser.Document msg, update : msg -> model -> ( model, Platform.Cmd.Cmd msg ), subscriptions : model -> Platform.Sub.Sub msg }, ports : Ports msg, protocol : Protocol serverMsg clientMsg model msg x } -> { document : Platform.Program flags model (FrameworkMsg msg), sendToServer : clientMsg -> Platform.Task Http.Error (Result x serverMsg) }
Returns a Browser.document
to use as main
in your client app
and a sendToServer
function to send clientMsg
with
application : { application : { init : flags -> Url -> Browser.Navigation.Key -> ( model, Platform.Cmd.Cmd msg ), view : model -> Browser.Document msg, update : msg -> model -> ( model, Platform.Cmd.Cmd msg ), subscriptions : model -> Platform.Sub.Sub msg, onUrlRequest : Browser.UrlRequest -> msg, onUrlChange : Url -> msg }, ports : Ports msg, protocol : Protocol serverMsg clientMsg model msg x } -> { application : Platform.Program flags model (FrameworkMsg msg), sendToServer : clientMsg -> Platform.Task Http.Error (Result x serverMsg) }
Returns a Browser.application
to use as main
in your client app
and a sendToServer
function to send clientMsg
with