From 17322676e0aab070e9a3e9497babbf0c856f03f4 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 22 Mar 2026 10:44:27 +0100 Subject: tools: websocket: Implement cover close / open This implements the minimal functionality to control covers with the Sia server in the development tool. Based on that the actual Sia server software can be adapted. --- tools/websocket.go | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tools/websocket.go b/tools/websocket.go index 594cb1b..af23959 100644 --- a/tools/websocket.go +++ b/tools/websocket.go @@ -16,6 +16,7 @@ import ( "os/signal" "strings" "syscall" + "time" "github.com/gorilla/websocket" ) @@ -38,6 +39,9 @@ func main() { go rx(c) getConfig(c) + coverClose(c) + time.Sleep(1 * time.Second) + coverOpen(c) Await(syscall.SIGTERM, syscall.SIGINT) } @@ -65,7 +69,7 @@ func Await(signals ...os.Signal) { } func getConfig(c *websocket.Conn) { - request := ` + tx(c, ` { "jsonrpc":"2.0", "id": 1, @@ -75,9 +79,35 @@ func getConfig(c *websocket.Conn) { "id":2 } } -` +`) +} - tx(c, request) +func coverClose(c *websocket.Conn) { + tx(c, ` +{ + "jsonrpc":"2.0", + "id": 1, + "src":"user_1", + "method":"Cover.Close", + "params": { + "id":0 + } +} +`) +} + +func coverOpen(c *websocket.Conn) { + tx(c, ` +{ + "jsonrpc":"2.0", + "id": 1, + "src":"user_1", + "method":"Cover.Open", + "params": { + "id":0 + } +} +`) } func rx(c *websocket.Conn) { -- cgit v1.3