mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
updated session events.
This commit is contained in:
parent
cf47b7e2fa
commit
1f5c0a3547
@ -63,6 +63,7 @@ func (manager *SessionManagerCtx) Create(id string, profile types.MemberProfile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
manager.members[id] = session
|
manager.members[id] = session
|
||||||
|
manager.emmiter.Emit("created", session)
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ func (manager *SessionManagerCtx) Delete(id string) error {
|
|||||||
return fmt.Errorf("Member not found.")
|
return fmt.Errorf("Member not found.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manager.emmiter.Emit("deleted", session)
|
||||||
delete(manager.members, id)
|
delete(manager.members, id)
|
||||||
|
|
||||||
if session.IsConnected() {
|
if session.IsConnected() {
|
||||||
@ -214,6 +216,18 @@ func (manager *SessionManagerCtx) OnHostCleared(listener func(session types.Sess
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *SessionManagerCtx) OnCreated(listener func(session types.Session)) {
|
||||||
|
manager.emmiter.On("created", func(payload ...interface{}) {
|
||||||
|
listener(payload[0].(*SessionCtx))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (manager *SessionManagerCtx) OnDeleted(listener func(session types.Session)) {
|
||||||
|
manager.emmiter.On("deleted", func(payload ...interface{}) {
|
||||||
|
listener(payload[0].(*SessionCtx))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (manager *SessionManagerCtx) OnConnected(listener func(session types.Session)) {
|
func (manager *SessionManagerCtx) OnConnected(listener func(session types.Session)) {
|
||||||
manager.emmiter.On("connected", func(payload ...interface{}) {
|
manager.emmiter.On("connected", func(payload ...interface{}) {
|
||||||
listener(payload[0].(*SessionCtx))
|
listener(payload[0].(*SessionCtx))
|
||||||
@ -238,6 +252,12 @@ func (manager *SessionManagerCtx) OnReceivingStopped(listener func(session types
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *SessionManagerCtx) OnProfileUpdated(listener func(session types.Session)) {
|
||||||
|
manager.emmiter.On("profile_updated", func(payload ...interface{}) {
|
||||||
|
listener(payload[0].(*SessionCtx))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
// config
|
// config
|
||||||
// ---
|
// ---
|
||||||
|
@ -61,6 +61,7 @@ func (session *SessionCtx) CanAccessClipboard() bool {
|
|||||||
|
|
||||||
func (session *SessionCtx) SetProfile(profile types.MemberProfile) {
|
func (session *SessionCtx) SetProfile(profile types.MemberProfile) {
|
||||||
session.profile = profile
|
session.profile = profile
|
||||||
|
session.manager.emmiter.Emit("profile_updated", session)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
@ -58,8 +58,13 @@ type SessionManager interface {
|
|||||||
|
|
||||||
OnHost(listener func(session Session))
|
OnHost(listener func(session Session))
|
||||||
OnHostCleared(listener func(session Session))
|
OnHostCleared(listener func(session Session))
|
||||||
|
OnCreated(listener func(session Session))
|
||||||
|
OnDeleted(listener func(session Session))
|
||||||
OnConnected(listener func(session Session))
|
OnConnected(listener func(session Session))
|
||||||
OnDisconnected(listener func(session Session))
|
OnDisconnected(listener func(session Session))
|
||||||
|
OnReceivingStarted(listener func(session Session))
|
||||||
|
OnReceivingStopped(listener func(session Session))
|
||||||
|
OnProfileUpdated(listener func(session Session))
|
||||||
|
|
||||||
ImplicitHosting() bool
|
ImplicitHosting() bool
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user