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