Browse Source

Fix rpjios plugin bug when list is prematurely empty

master
Ryan Joseph 1 month ago
parent
commit
672f4b55c6
2 changed files with 10 additions and 1 deletions
  1. +4
    -0
      main.go
  2. +6
    -1
      plugins/rpjios/main.go

+ 4
- 0
main.go View File

@@ -208,6 +208,7 @@ func (sh *subscribeHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
}

func readUntilClose(c *websocket.Conn) {
log.Printf("readUntilClose for %v STARTING\n", c.RemoteAddr())
for {
if _, _, err := c.NextReader(); err != nil {
remoteAddr := c.RemoteAddr()
@@ -224,9 +225,11 @@ func readUntilClose(c *websocket.Conn) {
break
}
}
log.Printf("readUntilClose for %v EXITING\n", c.RemoteAddr())
}

func forwardAllOnto(wsc wsClient) {
log.Printf("forAllOnto for %v STARTING\n", wsc.Conn.RemoteAddr())
for fwd := range wsc.Sub.Channel() {
payload := interface{}(fwd.Payload)
var err error
@@ -246,6 +249,7 @@ func forwardAllOnto(wsc wsClient) {
wsc.Conn.WriteJSON(payload)
}()
}
log.Printf("forAllOnto for %v EXITING\n", wsc.Conn.RemoteAddr())
}

func registerNewClient(wsConn *websocket.Conn, channel string) {


+ 6
- 1
plugins/rpjios/main.go View File

@@ -13,7 +13,7 @@ import (
var hostname string

func Version() string {
return "0.0.1"
return "0.0.2"
}

func HandleMsg(payload interface{}) (interface{}, error) {
@@ -85,6 +85,11 @@ func HandleListReq(dir string, file string, query url.Values, listLookup RhpHand
break
}

if len(list) == 0 {
stillGoing = false
break
}

for _, toDec := range list {
var newVal [2]float64
err = json.Unmarshal([]byte(toDec), &newVal)


Loading…
Cancel
Save