mirror of
https://github.com/kataras/iris.git
synced 2025-03-21 11:06:26 +01:00
Some fixes to the previous edit
Former-commit-id: da5219084b60d820ced713feff837e3964fa1fb0
This commit is contained in:
parent
9061d3d695
commit
1cd9b70791
|
@ -106,7 +106,7 @@ type (
|
||||||
config Config
|
config Config
|
||||||
connections connections
|
connections connections
|
||||||
rooms map[string][]string // by default a connection is joined to a room which has the connection id as its name
|
rooms map[string][]string // by default a connection is joined to a room which has the connection id as its name
|
||||||
mu sync.RWMutex // for rooms
|
mu sync.RWMutex // for rooms
|
||||||
onConnectionListeners []ConnectionFunc
|
onConnectionListeners []ConnectionFunc
|
||||||
//connectionPool sync.Pool // sadly we can't make this because the websocket connection is live until is closed.
|
//connectionPool sync.Pool // sadly we can't make this because the websocket connection is live until is closed.
|
||||||
handler context.Handler
|
handler context.Handler
|
||||||
|
@ -308,7 +308,7 @@ func (s *Server) leave(roomName string, connID string) (left bool) {
|
||||||
// GetTotalConnections returns the number of total connections
|
// GetTotalConnections returns the number of total connections
|
||||||
func (s *Server) GetTotalConnections() int {
|
func (s *Server) GetTotalConnections() int {
|
||||||
s.mu.RLock()
|
s.mu.RLock()
|
||||||
l:= len(s.connections)
|
l := len(s.connections)
|
||||||
s.mu.RUnlock()
|
s.mu.RUnlock()
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
@ -316,8 +316,10 @@ func (s *Server) GetTotalConnections() int {
|
||||||
// GetConnections returns all connections
|
// GetConnections returns all connections
|
||||||
func (s *Server) GetConnections() []Connection {
|
func (s *Server) GetConnections() []Connection {
|
||||||
s.mu.RLock()
|
s.mu.RLock()
|
||||||
conns:= make([]Connection, len(s.connections))
|
conns := make([]Connection, len(s.connections), len(s.connections))
|
||||||
copy(conns, s.connections)
|
for i, c := range s.connections {
|
||||||
|
conns[i] = c.value
|
||||||
|
}
|
||||||
s.mu.RUnlock()
|
s.mu.RUnlock()
|
||||||
return conns
|
return conns
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user