mirror of https://github.com/tidwall/tile38.git
Use the right MSG variable?
This commit is contained in:
parent
61b5023000
commit
c45170d211
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue