Fix ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context #694
This commit is contained in:
parent
d7a766c6d0
commit
ec47a58ba1
@ -205,6 +205,23 @@ func (s *Server) liveSubscription(
|
|||||||
write([]byte("+OK\r\n"))
|
write([]byte("+OK\r\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
writePing := func() {
|
||||||
|
switch msg.OutputType {
|
||||||
|
case JSON:
|
||||||
|
if len(msg.Args) > 1 {
|
||||||
|
write([]byte(`{"ok":true,"ping":` + jsonString(msg.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.AppendBulkString(nil, msg.Args[1])
|
||||||
|
write(data)
|
||||||
|
} else {
|
||||||
|
write([]byte("+PONG\r\n"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
writeWrongNumberOfArgsErr := func(command string) {
|
writeWrongNumberOfArgsErr := func(command string) {
|
||||||
switch outputType {
|
switch outputType {
|
||||||
case JSON:
|
case JSON:
|
||||||
@ -335,6 +352,9 @@ func (s *Server) liveSubscription(
|
|||||||
case "quit":
|
case "quit":
|
||||||
writeOK()
|
writeOK()
|
||||||
return nil
|
return nil
|
||||||
|
case "ping":
|
||||||
|
writePing()
|
||||||
|
continue
|
||||||
case "psubscribe":
|
case "psubscribe":
|
||||||
kind, un = pubsubPattern, false
|
kind, un = pubsubPattern, false
|
||||||
case "punsubscribe":
|
case "punsubscribe":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user