|
|
|
@ -30,6 +30,7 @@ import (
@@ -30,6 +30,7 @@ import (
|
|
|
|
|
"github.com/gorilla/securecookie" |
|
|
|
|
"log" |
|
|
|
|
"sync" |
|
|
|
|
"sync/atomic" |
|
|
|
|
"time" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -51,6 +52,8 @@ type HubStat struct {
@@ -51,6 +52,8 @@ type HubStat struct {
|
|
|
|
|
Connections int `json:"connections"` |
|
|
|
|
Users int `json:"users"` |
|
|
|
|
Count uint64 `json:"count"` |
|
|
|
|
BroadcastChatMessages uint64 `json:"broadcastchatmessages"` |
|
|
|
|
UnicastChatMessages uint64 `json:"unicastchatmessages"` |
|
|
|
|
IdsInRoom map[string][]string `json:"idsinroom,omitempty"` |
|
|
|
|
UsersById map[string]*DataUser `json:"usersbyid,omitempty"` |
|
|
|
|
ConnectionsByIdx map[string]string `json:"connectionsbyidx,omitempty"` |
|
|
|
@ -69,6 +72,8 @@ type Hub struct {
@@ -69,6 +72,8 @@ type Hub struct {
|
|
|
|
|
count uint64 |
|
|
|
|
mutex sync.RWMutex |
|
|
|
|
buffers BufferCache |
|
|
|
|
broadcastChatMessages uint64 |
|
|
|
|
unicastChatMessages uint64 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewHub(version string, config *Config, sessionSecret string, turnSecret string) *Hub { |
|
|
|
@ -97,6 +102,8 @@ func (h *Hub) Stat(details bool) *HubStat {
@@ -97,6 +102,8 @@ func (h *Hub) Stat(details bool) *HubStat {
|
|
|
|
|
Connections: len(h.connectionTable), |
|
|
|
|
Users: len(h.userTable), |
|
|
|
|
Count: h.count, |
|
|
|
|
BroadcastChatMessages: atomic.LoadUint64(&h.broadcastChatMessages), |
|
|
|
|
UnicastChatMessages: atomic.LoadUint64(&h.unicastChatMessages), |
|
|
|
|
} |
|
|
|
|
if details { |
|
|
|
|
rooms := make(map[string][]string) |
|
|
|
|