neko/internal/types/session.go

42 lines
898 B
Go
Raw Normal View History

package types
type Session interface {
ID() string
Name() string
Admin() bool
Muted() bool
IsHost() bool
Connected() bool
2020-11-02 04:09:48 +13:00
Address() string
SetMuted(muted bool)
2020-11-01 09:46:29 +13:00
SetName(name string)
SetSocket(socket WebSocket)
SetPeer(peer Peer)
2020-11-02 04:09:48 +13:00
SetConnected()
Disconnect(reason string) error
Send(v interface{}) error
SignalAnswer(sdp string) error
}
type SessionManager interface {
New(id string, admin bool, socket WebSocket) Session
2020-11-02 04:09:48 +13:00
Get(id string) (Session, bool)
Has(id string) bool
Destroy(id string) error
HasHost() bool
2020-11-02 04:09:48 +13:00
SetHost(host Session)
GetHost() Session
ClearHost()
2020-11-02 04:09:48 +13:00
Admins() []Session
Members() []Session
Broadcast(v interface{}, exclude interface{}) error
2020-11-02 04:09:48 +13:00
2020-11-01 11:03:37 +13:00
OnHost(listener func(session Session))
OnHostCleared(listener func(session Session))
OnDestroy(listener func(id string))
2020-11-01 11:03:37 +13:00
OnCreated(listener func(session Session))
OnConnected(listener func(session Session))
}