MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / UpdateStats

Method UpdateStats

world.go:646–686  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

644}
645
646func (w *World) UpdateStats() {
647 s := web.GetStats()
648 s.Reset()
649
650 c := configs.GetNetworkConfig()
651
652 for _, u := range users.GetAllActiveUsers() {
653 info := u.GetOnlineInfo()
654 s.OnlineUsers = append(s.OnlineUsers, info)
655 switch info.ConnType {
656 case "websocket":
657 s.WebSocketConnections++
658 case "ssh":
659 s.SSHConnections++
660 default:
661 s.TelnetConnections++
662 }
663 }
664
665 sort.Slice(s.OnlineUsers, func(i, j int) bool {
666 if s.OnlineUsers[i].Role == users.RoleAdmin {
667 return true
668 }
669 if s.OnlineUsers[j].Role == users.RoleAdmin {
670 return false
671 }
672 return s.OnlineUsers[i].OnlineTime > s.OnlineUsers[j].OnlineTime
673 })
674
675 for _, t := range c.TelnetPort {
676 p, _ := strconv.Atoi(t)
677 if p > 0 {
678 s.TelnetPorts = append(s.TelnetPorts, p)
679 }
680 }
681
682 s.WebSocketPort = int(c.HttpPort)
683 s.SSHPort = int(c.SSHPort)
684
685 web.UpdateStats(s)
686}
687
688// Force disconnect a user (Makes them linkdead)
689func (w *World) Kick(userId int, reason string) {

Callers 2

enterWorldMethod · 0.95
MainWorkerMethod · 0.95

Calls 6

GetStatsFunction · 0.92
GetNetworkConfigFunction · 0.92
GetAllActiveUsersFunction · 0.92
UpdateStatsFunction · 0.92
GetOnlineInfoMethod · 0.80
ResetMethod · 0.45

Tested by

no test coverage detected