mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add MemberProfile to session.
This commit is contained in:
parent
b73e2403af
commit
bc77c8f8f5
@ -42,9 +42,11 @@ func (manager *SessionManagerCtx) New(id string, admin bool) types.Session {
|
||||
|
||||
session := &SessionCtx{
|
||||
id: id,
|
||||
admin: admin,
|
||||
manager: manager,
|
||||
logger: manager.logger.With().Str("id", id).Logger(),
|
||||
profile: MemberProfile{
|
||||
is_admin: admin,
|
||||
},
|
||||
connected: false,
|
||||
}
|
||||
|
||||
@ -116,7 +118,7 @@ func (manager *SessionManagerCtx) Admins() []types.Session {
|
||||
|
||||
var sessions []types.Session
|
||||
for _, session := range manager.members {
|
||||
if !session.connected || !session.admin {
|
||||
if !session.Connected() || !session.Admin() {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -132,7 +134,7 @@ func (manager *SessionManagerCtx) Members() []types.Session {
|
||||
|
||||
var sessions []types.Session
|
||||
for _, session := range manager.members {
|
||||
if !session.connected {
|
||||
if !session.Connected() {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -147,7 +149,7 @@ func (manager *SessionManagerCtx) Broadcast(v interface{}, exclude interface{})
|
||||
defer manager.membersMu.Unlock()
|
||||
|
||||
for id, session := range manager.members {
|
||||
if !session.connected {
|
||||
if !session.Connected() {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -168,7 +170,7 @@ func (manager *SessionManagerCtx) AdminBroadcast(v interface{}, exclude interfac
|
||||
defer manager.membersMu.Unlock()
|
||||
|
||||
for id, session := range manager.members {
|
||||
if !session.connected || !session.Admin() {
|
||||
if !session.Connected() || !session.Admin() {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -8,15 +8,24 @@ import (
|
||||
"demodesk/neko/internal/types/message"
|
||||
)
|
||||
|
||||
type SessionCtx struct {
|
||||
logger zerolog.Logger
|
||||
id string
|
||||
type MemberProfile struct {
|
||||
token string
|
||||
name string
|
||||
admin bool
|
||||
connected bool
|
||||
is_admin bool
|
||||
enabled bool
|
||||
can_control bool
|
||||
can_watch bool
|
||||
clipboard_access bool
|
||||
}
|
||||
|
||||
type SessionCtx struct {
|
||||
id string
|
||||
logger zerolog.Logger
|
||||
manager *SessionManagerCtx
|
||||
profile MemberProfile
|
||||
websocket_peer types.WebSocketPeer
|
||||
webrtc_peer types.WebRTCPeer
|
||||
connected bool
|
||||
}
|
||||
|
||||
func (session *SessionCtx) ID() string {
|
||||
@ -24,11 +33,11 @@ func (session *SessionCtx) ID() string {
|
||||
}
|
||||
|
||||
func (session *SessionCtx) Name() string {
|
||||
return session.name
|
||||
return session.profile.name
|
||||
}
|
||||
|
||||
func (session *SessionCtx) Admin() bool {
|
||||
return session.admin
|
||||
return session.profile.is_admin
|
||||
}
|
||||
|
||||
func (session *SessionCtx) IsHost() bool {
|
||||
@ -40,7 +49,7 @@ func (session *SessionCtx) Connected() bool {
|
||||
}
|
||||
|
||||
func (session *SessionCtx) SetName(name string) {
|
||||
session.name = name
|
||||
session.profile.name = name
|
||||
}
|
||||
|
||||
func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer) {
|
||||
|
Loading…
Reference in New Issue
Block a user