diff options
| author | xengineering <me@xengineering.eu> | 2026-03-22 10:44:27 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-03-22 10:44:27 +0100 |
| commit | 17322676e0aab070e9a3e9497babbf0c856f03f4 (patch) | |
| tree | bfe87bcbf59dcc5a7fce0109415eead661c280e1 | |
| parent | 992320029e1375b0fd9caa95573881732161719f (diff) | |
| download | sia-server-17322676e0aab070e9a3e9497babbf0c856f03f4.tar sia-server-17322676e0aab070e9a3e9497babbf0c856f03f4.tar.zst sia-server-17322676e0aab070e9a3e9497babbf0c856f03f4.zip | |
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.
| -rw-r--r-- | tools/websocket.go | 36 |
1 files 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) { |
