From 4a65dd5a7a8063567322f09a1ad07ab99502fc69 Mon Sep 17 00:00:00 2001 From: taoshihan1991 <630892807@qq.com> Date: Mon, 6 Jul 2020 15:34:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E7=BA=BF=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=B7=B3=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/chat.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controller/chat.go b/controller/chat.go index 65ebc2f..a5b491f 100644 --- a/controller/chat.go +++ b/controller/chat.go @@ -6,6 +6,7 @@ import ( "github.com/gorilla/websocket" "github.com/taoshihan1991/imaptool/models" "log" + "sort" "time" ) type vistor struct{ @@ -130,7 +131,13 @@ func sendPingUpdateStatus() { func sendPingOnlineUsers() { for { result := make([]map[string]string, 0) - for _, user := range clientList { + var visitorIds []string + for visitorId, _ := range clientList { + visitorIds=append(visitorIds,visitorId) + } + sort.Strings(visitorIds) + for _,visitorId:=range visitorIds{ + user:=clientList[visitorId] userInfo := make(map[string]string) userInfo["uid"] = user.id userInfo["username"] = user.name