Pebble.Companion.WebSocket
WebSocket commands and events through the phone companion bridge.
init _ =
( model, WebSocket.connect "wss://example.com/live" Connected )
subscriptions _ =
WebSocket.onWebSocket WebSocketChangedEvents
Event
type Event
= Opened
| Closed (Maybe Int)
| Message String
| Error String
| Unknown StringWebSocket events emitted by the companion bridge.
Commands
connect
connect : String -> (Result String () -> msg) -> Cmd msgOpen a WebSocket connection.
disconnect
disconnect : (Result String () -> msg) -> Cmd msgClose the active WebSocket connection.
send
send : String -> (Result String () -> msg) -> Cmd msgSend a string message over the active WebSocket.
setup
setup : Cmd msgRegister the WebSocket event platform handler with the companion bridge.
setupCommands
setupCommands : Cmd msgRegister the WebSocket command platform handler with the companion bridge.
Subscriptions
onWebSocket
onWebSocket : (Event -> msg) -> Sub msgReceive pushed WebSocket events from the companion bridge.
Registering this subscription also tells the bridge to send WebSocket updates.
onCommands
onCommands : (Result String () -> msg) -> Sub msgReceive WebSocket command responses on the dedicated WebSocket port.