Pebble.Companion.WebSocket

WebSocket commands and events through the phone companion bridge.

init _ =
    ( model, WebSocket.connect "wss://example.com/live" Connected )

subscriptions _ =
    WebSocket.onWebSocket WebSocketChanged

Events

Event

type Event
    = Opened
    | Closed (Maybe Int)
    | Message String
    | Error String
    | Unknown String

WebSocket events emitted by the companion bridge.

Commands

connect

connect : String -> (Result String () -> msg) -> Cmd msg

Open a WebSocket connection.

disconnect

disconnect : (Result String () -> msg) -> Cmd msg

Close the active WebSocket connection.

send

send : String -> (Result String () -> msg) -> Cmd msg

Send a string message over the active WebSocket.

setup

setup : Cmd msg

Register the WebSocket event platform handler with the companion bridge.

setupCommands

setupCommands : Cmd msg

Register the WebSocket command platform handler with the companion bridge.

Subscriptions

onWebSocket

onWebSocket : (Event -> msg) -> Sub msg

Receive pushed WebSocket events from the companion bridge.

Registering this subscription also tells the bridge to send WebSocket updates.

onCommands

onCommands : (Result String () -> msg) -> Sub msg

Receive WebSocket command responses on the dedicated WebSocket port.