2020-10-23 03:54:50 +13:00
|
|
|
package types
|
|
|
|
|
|
|
|
type Member struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Name string `json:"displayname"`
|
|
|
|
Admin bool `json:"admin"`
|
|
|
|
Muted bool `json:"muted"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Session interface {
|
|
|
|
ID() string
|
|
|
|
Name() string
|
|
|
|
Admin() bool
|
|
|
|
Muted() bool
|
2020-11-01 09:20:42 +13:00
|
|
|
IsHost() bool
|
2020-10-23 03:54:50 +13:00
|
|
|
Connected() bool
|
|
|
|
Member() *Member
|
|
|
|
SetMuted(muted bool)
|
2020-11-01 09:46:29 +13:00
|
|
|
SetName(name string)
|
|
|
|
SetConnected()
|
|
|
|
SetSocket(socket WebSocket)
|
|
|
|
SetPeer(peer Peer)
|
2020-10-23 03:54:50 +13:00
|
|
|
Address() string
|
2020-11-01 09:20:42 +13:00
|
|
|
Disconnect(message string) error
|
2020-10-23 03:54:50 +13:00
|
|
|
Send(v interface{}) error
|
|
|
|
SignalAnswer(sdp string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type SessionManager interface {
|
|
|
|
New(id string, admin bool, socket WebSocket) Session
|
|
|
|
HasHost() bool
|
|
|
|
SetHost(id string) error
|
|
|
|
GetHost() (Session, bool)
|
|
|
|
ClearHost()
|
|
|
|
Has(id string) bool
|
|
|
|
Get(id string) (Session, bool)
|
|
|
|
Members() []*Member
|
|
|
|
Admins() []*Member
|
|
|
|
Destroy(id string) error
|
|
|
|
Broadcast(v interface{}, exclude interface{}) error
|
2020-11-01 11:03:37 +13:00
|
|
|
OnHost(listener func(session Session))
|
|
|
|
OnHostCleared(listener func(session Session))
|
|
|
|
OnBeforeDestroy(listener func(session Session))
|
|
|
|
OnCreated(listener func(session Session))
|
|
|
|
OnConnected(listener func(session Session))
|
2020-10-23 03:54:50 +13:00
|
|
|
}
|