Use the right MSG variable?

This commit is contained in:
Chris Rice 2023-07-26 11:47:11 -07:00
parent 61b5023000
commit c45170d211
1 changed files with 10 additions and 10 deletions

View File

@ -205,23 +205,23 @@ func (s *Server) liveSubscription(
write([]byte("+OK\r\n")) write([]byte("+OK\r\n"))
} }
} }
writePing := func() { writePing := func(m *Message) {
switch outputType { switch outputType {
case JSON: case JSON:
if len(msg.Args) > 1 { if len(m.Args) > 1 {
write([]byte(`{"ok":true,"ping":` + jsonString(msg.Args[1]) + `,"elapsed":"` + time.Since(start).String() + `"}`)) write([]byte(`{"ok":true,"ping":` + jsonString(m.Args[1]) + `,"elapsed":"` + time.Since(start).String() + `"}`))
} else { } else {
write([]byte(`{"ok":true,"ping":"pong","elapsed":"` + time.Since(start).String() + `"}`)) write([]byte(`{"ok":true,"ping":"pong","elapsed":"` + time.Since(start).String() + `"}`))
} }
case RESP: case RESP:
if len(msg.Args) > 1 {
data := redcon.AppendArray(nil, 2) data := redcon.AppendArray(nil, 2)
data = redcon.AppendBulkString(data, "PONG") data = redcon.AppendBulkString(data, "PONG")
data = redcon.AppendBulkString(data, msg.Args[1]) if len(m.Args) > 1 {
write(data) data = redcon.AppendBulkString(data, m.Args[1])
} else { } else {
write([]byte("+PONG\r\n")) data = redcon.AppendBulkString(data, "")
} }
write(data)
} }
} }
writeWrongNumberOfArgsErr := func(command string) { writeWrongNumberOfArgsErr := func(command string) {
@ -355,7 +355,7 @@ func (s *Server) liveSubscription(
writeOK() writeOK()
return nil return nil
case "ping": case "ping":
writePing() writePing(msg)
continue continue
case "psubscribe": case "psubscribe":
kind, un = pubsubPattern, false kind, un = pubsubPattern, false