mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
HasConnectedMembers and Members returns not connected.
This commit is contained in:
parent
5541675f57
commit
82d37b15e4
@ -131,20 +131,17 @@ func (manager *SessionManagerCtx) ClearHost() {
|
|||||||
// ---
|
// ---
|
||||||
// members list
|
// members list
|
||||||
// ---
|
// ---
|
||||||
func (manager *SessionManagerCtx) Admins() []types.Session {
|
func (manager *SessionManagerCtx) HasConnectedMembers() bool {
|
||||||
manager.membersMu.Lock()
|
manager.membersMu.Lock()
|
||||||
defer manager.membersMu.Unlock()
|
defer manager.membersMu.Unlock()
|
||||||
|
|
||||||
var sessions []types.Session
|
|
||||||
for _, session := range manager.members {
|
for _, session := range manager.members {
|
||||||
if !session.IsConnected() || !session.IsAdmin() {
|
if session.IsConnected() {
|
||||||
continue
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sessions = append(sessions, session)
|
return false
|
||||||
}
|
|
||||||
|
|
||||||
return sessions
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *SessionManagerCtx) Members() []types.Session {
|
func (manager *SessionManagerCtx) Members() []types.Session {
|
||||||
@ -153,10 +150,6 @@ func (manager *SessionManagerCtx) Members() []types.Session {
|
|||||||
|
|
||||||
var sessions []types.Session
|
var sessions []types.Session
|
||||||
for _, session := range manager.members {
|
for _, session := range manager.members {
|
||||||
if !session.IsConnected() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
sessions = append(sessions, session)
|
sessions = append(sessions, session)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +227,7 @@ func (manager *SessionManagerCtx) OnConnected(listener func(session types.Sessio
|
|||||||
func (manager *SessionManagerCtx) OnDisconnected(listener func(session types.Session)) {
|
func (manager *SessionManagerCtx) OnDisconnected(listener func(session types.Session)) {
|
||||||
manager.emmiter.On("disconnected", func(payload ...interface{}) {
|
manager.emmiter.On("disconnected", func(payload ...interface{}) {
|
||||||
// Stop streaming, if everyone left
|
// Stop streaming, if everyone left
|
||||||
if manager.capture.Streaming() && len(manager.Members()) == 0 {
|
if manager.capture.Streaming() && !manager.HasConnectedMembers() {
|
||||||
manager.capture.StopStream()
|
manager.capture.StopStream()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ type SessionManager interface {
|
|||||||
GetHost() Session
|
GetHost() Session
|
||||||
ClearHost()
|
ClearHost()
|
||||||
|
|
||||||
Admins() []Session
|
|
||||||
Members() []Session
|
Members() []Session
|
||||||
Broadcast(v interface{}, exclude interface{})
|
Broadcast(v interface{}, exclude interface{})
|
||||||
AdminBroadcast(v interface{}, exclude interface{})
|
AdminBroadcast(v interface{}, exclude interface{})
|
||||||
|
Loading…
Reference in New Issue
Block a user