// JS websocket part for esp32 server_http_ws template
// Copyright by Anthony Vogelaar, Perth Scotland
// rev 0.10  2025-12-05 initial release

// ====================== websocket ============================

const	wsock	= new WebSocket("ws://" + location.hostname + ":5000/ws")

// send obj in json through ws
function wsSend(obj) {
    data = {data:obj}
    wsock.send(JSON.stringify(data))
}


// handle incoming ws json message = 4-array
function wsOnMessage(ev) {
   let obj = JSON.parse(ev.data)
   setLeds(obj)
}

// ========================= end ==============================
