修复在线用户跳动

pull/30/head
taoshihan1991 5 years ago
parent 3af3088b85
commit 4a65dd5a7a

@ -6,6 +6,7 @@ import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/taoshihan1991/imaptool/models" "github.com/taoshihan1991/imaptool/models"
"log" "log"
"sort"
"time" "time"
) )
type vistor struct{ type vistor struct{
@ -130,7 +131,13 @@ func sendPingUpdateStatus() {
func sendPingOnlineUsers() { func sendPingOnlineUsers() {
for { for {
result := make([]map[string]string, 0) 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 := make(map[string]string)
userInfo["uid"] = user.id userInfo["uid"] = user.id
userInfo["username"] = user.name userInfo["username"] = user.name

Loading…
Cancel
Save