mirror of https://github.com/tidwall/tile38.git
Fix invalid pubsub format for json output
This commit fixes a bug that causes bad formatting for geofence notifications when a client's output is set to JSON. closes #499
This commit is contained in:
parent
d2cfb87c89
commit
10f7bfc445
|
@ -8,6 +8,7 @@ import (
|
|||
"net"
|
||||
"sync"
|
||||
|
||||
"github.com/tidwall/redcon"
|
||||
"github.com/tidwall/tile38/internal/log"
|
||||
)
|
||||
|
||||
|
@ -160,9 +161,9 @@ func (server *Server) goLive(
|
|||
var livemsg []byte
|
||||
switch outputType {
|
||||
case JSON:
|
||||
livemsg = []byte(`{"ok":true,"live":true}`)
|
||||
livemsg = redcon.AppendBulkString(nil, `{"ok":true,"live":true}`)
|
||||
case RESP:
|
||||
livemsg = []byte("+OK\r\n")
|
||||
livemsg = redcon.AppendOK(nil)
|
||||
}
|
||||
if err := writeLiveMessage(conn, livemsg, false, connType, websocket); err != nil {
|
||||
return nil // nil return is fine here
|
||||
|
|
|
@ -194,7 +194,7 @@ func (c *Server) liveSubscription(
|
|||
write := func(data []byte) {
|
||||
writeLock.Lock()
|
||||
defer writeLock.Unlock()
|
||||
writeLiveMessage(conn, data, false, connType, websocket)
|
||||
writeLiveMessage(conn, data, outputType == JSON, connType, websocket)
|
||||
}
|
||||
writeOK := func() {
|
||||
switch outputType {
|
||||
|
|
Loading…
Reference in New Issue