From d810d12355873d3eaf61ed3f7f0ae52db06c2c96 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 8 Dec 2024 08:45:13 +0800 Subject: Add basic command handling --- cmd_ping.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cmd_ping.go (limited to 'cmd_ping.go') diff --git a/cmd_ping.go b/cmd_ping.go new file mode 100644 index 0000000..4ad07c5 --- /dev/null +++ b/cmd_ping.go @@ -0,0 +1,13 @@ +package main + +func init() { + commandHandlers["PING"] = handleClientPing +} + +func handleClientPing(msg RMsg, client *Client) (error) { + if len(msg.Params) < 1 { + client.Send(SMsg{Command: ERR_NEEDMOREPARAMS, Params: []string{"PING", "Not enough parameters"}}) + } + client.Send(SMsg{Command: "PONG", Params: []string{msg.Params[0]}}) + return nil +} -- cgit v1.2.3