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{
|
session := &SessionCtx{
|
||||||
id: id,
|
id: id,
|
||||||
admin: admin,
|
|
||||||
manager: manager,
|
manager: manager,
|
||||||
logger: manager.logger.With().Str("id", id).Logger(),
|
logger: manager.logger.With().Str("id", id).Logger(),
|
||||||
|
profile: MemberProfile{
|
||||||
|
is_admin: admin,
|
||||||
|
},
|
||||||
connected: false,
|
connected: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +118,7 @@ func (manager *SessionManagerCtx) Admins() []types.Session {
|
|||||||
|
|
||||||
var sessions []types.Session
|
var sessions []types.Session
|
||||||
for _, session := range manager.members {
|
for _, session := range manager.members {
|
||||||
if !session.connected || !session.admin {
|
if !session.Connected() || !session.Admin() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +134,7 @@ 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.connected {
|
if !session.Connected() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +149,7 @@ func (manager *SessionManagerCtx) Broadcast(v interface{}, exclude interface{})
|
|||||||
defer manager.membersMu.Unlock()
|
defer manager.membersMu.Unlock()
|
||||||
|
|
||||||
for id, session := range manager.members {
|
for id, session := range manager.members {
|
||||||
if !session.connected {
|
if !session.Connected() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +170,7 @@ func (manager *SessionManagerCtx) AdminBroadcast(v interface{}, exclude interfac
|
|||||||
defer manager.membersMu.Unlock()
|
defer manager.membersMu.Unlock()
|
||||||
|
|
||||||
for id, session := range manager.members {
|
for id, session := range manager.members {
|
||||||
if !session.connected || !session.Admin() {
|
if !session.Connected() || !session.Admin() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,15 +8,24 @@ import (
|
|||||||
"demodesk/neko/internal/types/message"
|
"demodesk/neko/internal/types/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SessionCtx struct {
|
type MemberProfile struct {
|
||||||
logger zerolog.Logger
|
token string
|
||||||
id string
|
|
||||||
name string
|
name string
|
||||||
admin bool
|
is_admin bool
|
||||||
connected bool
|
enabled bool
|
||||||
|
can_control bool
|
||||||
|
can_watch bool
|
||||||
|
clipboard_access bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type SessionCtx struct {
|
||||||
|
id string
|
||||||
|
logger zerolog.Logger
|
||||||
manager *SessionManagerCtx
|
manager *SessionManagerCtx
|
||||||
|
profile MemberProfile
|
||||||
websocket_peer types.WebSocketPeer
|
websocket_peer types.WebSocketPeer
|
||||||
webrtc_peer types.WebRTCPeer
|
webrtc_peer types.WebRTCPeer
|
||||||
|
connected bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) ID() string {
|
func (session *SessionCtx) ID() string {
|
||||||
@ -24,11 +33,11 @@ func (session *SessionCtx) ID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) Name() string {
|
func (session *SessionCtx) Name() string {
|
||||||
return session.name
|
return session.profile.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) Admin() bool {
|
func (session *SessionCtx) Admin() bool {
|
||||||
return session.admin
|
return session.profile.is_admin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) IsHost() bool {
|
func (session *SessionCtx) IsHost() bool {
|
||||||
@ -40,7 +49,7 @@ func (session *SessionCtx) Connected() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) SetName(name string) {
|
func (session *SessionCtx) SetName(name string) {
|
||||||
session.name = name
|
session.profile.name = name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer) {
|
func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user