summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-03-22 10:44:27 +0100
committerxengineering <me@xengineering.eu>2026-03-23 16:55:47 +0100
commit589425d307cd7d06d3f7d052f6ea1a5245688d0d (patch)
tree59c4da27b522c6b8dfd645bf35aa36456c4d197f
parent10ef120da246e0e0eb2245e160792ed29e623a30 (diff)
downloadsia-server-589425d307cd7d06d3f7d052f6ea1a5245688d0d.tar
sia-server-589425d307cd7d06d3f7d052f6ea1a5245688d0d.tar.zst
sia-server-589425d307cd7d06d3f7d052f6ea1a5245688d0d.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.go36
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) {