From 792064066ffb7167ee9c3ebfa11dbcd76d3268b5 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Tue, 23 May 2023 14:58:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=B0=E6=B3=A8=E5=86=8C=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/event.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/event.go b/server/event.go index 75c6f51..05d0e4d 100644 --- a/server/event.go +++ b/server/event.go @@ -39,6 +39,8 @@ type event struct { } // RegConsoleCommandEvent 控制台收到指令时将立即执行被注册的事件处理函数 +// - 默认将注册 "exit", "quit", "close", "shutdown", "EXIT", "QUIT", "CLOSE", "SHUTDOWN" 指令作为关闭服务器的指令 +// - 可通过注册默认指令进行默认行为的覆盖 func (slf *event) RegConsoleCommandEvent(command string, handle ConsoleCommandEventHandle) { slf.consoleCommandEventHandleInitOnce.Do(func() { slf.consoleCommandEventHandles = map[string][]ConsoleCommandEventHandle{} @@ -49,7 +51,7 @@ func (slf *event) RegConsoleCommandEvent(command string, handle ConsoleCommandEv handles, exist := slf.consoleCommandEventHandles[input] if !exist { switch input { - case "exit", "quit", "close", "shutdown": + case "exit", "quit", "close", "shutdown", "EXIT", "QUIT", "CLOSE", "SHUTDOWN": log.Info("Console", zap.String("Receive", input), zap.String("Action", "Shutdown")) slf.Server.Shutdown(nil) return