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
|
||||
// ---
|
||||
func (manager *SessionManagerCtx) Admins() []types.Session {
|
||||
func (manager *SessionManagerCtx) HasConnectedMembers() bool {
|
||||
manager.membersMu.Lock()
|
||||
defer manager.membersMu.Unlock()
|
||||
|
||||
var sessions []types.Session
|
||||
for _, session := range manager.members {
|
||||
if !session.IsConnected() || !session.IsAdmin() {
|
||||
continue
|
||||
if session.IsConnected() {
|
||||
return true
|
||||
}
|
||||
|
||||
sessions = append(sessions, session)
|
||||
}
|
||||
|
||||
return sessions
|
||||
return false
|
||||
}
|
||||
|
||||
func (manager *SessionManagerCtx) Members() []types.Session {
|
||||
@ -153,10 +150,6 @@ func (manager *SessionManagerCtx) Members() []types.Session {
|
||||
|
||||
var sessions []types.Session
|
||||
for _, session := range manager.members {
|
||||
if !session.IsConnected() {
|
||||
continue
|
||||
}
|
||||
|
||||
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)) {
|
||||
manager.emmiter.On("disconnected", func(payload ...interface{}) {
|
||||
// Stop streaming, if everyone left
|
||||
if manager.capture.Streaming() && len(manager.Members()) == 0 {
|
||||
if manager.capture.Streaming() && !manager.HasConnectedMembers() {
|
||||
manager.capture.StopStream()
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ type SessionManager interface {
|
||||
GetHost() Session
|
||||
ClearHost()
|
||||
|
||||
Admins() []Session
|
||||
Members() []Session
|
||||
Broadcast(v interface{}, exclude interface{})
|
||||
AdminBroadcast(v interface{}, exclude interface{})
|
||||
|
Loading…
Reference in New Issue
Block a user