neko/internal/types/session.go
2020-11-01 21:03:25 +01:00

47 lines
982 B
Go

package types
import "net/http"
type Session interface {
ID() string
Name() string
Admin() bool
Muted() bool
IsHost() bool
Connected() bool
Address() string
SetMuted(muted bool)
SetName(name string)
SetSocket(socket WebSocket)
SetPeer(peer Peer)
SetConnected(connected bool)
Disconnect(reason string) error
Send(v interface{}) error
SignalAnswer(sdp string) error
}
type SessionManager interface {
New(id string, admin bool) Session
Get(id string) (Session, bool)
Has(id string) bool
Destroy(id string) error
HasHost() bool
SetHost(host Session)
GetHost() Session
ClearHost()
Admins() []Session
Members() []Session
Broadcast(v interface{}, exclude interface{}) error
OnHost(listener func(session Session))
OnHostCleared(listener func(session Session))
OnCreated(listener func(session Session))
OnConnected(listener func(session Session))
OnDisconnected(listener func(session Session))
// auth
Authenticate(r *http.Request) (Session, error)
}