2020-10-22 16:54:50 +02:00
|
|
|
package types
|
|
|
|
|
2020-11-01 18:39:12 +01:00
|
|
|
import "net/http"
|
|
|
|
|
2020-10-22 16:54:50 +02:00
|
|
|
type Session interface {
|
|
|
|
ID() string
|
|
|
|
Name() string
|
|
|
|
Admin() bool
|
|
|
|
Muted() bool
|
2020-10-31 21:20:42 +01:00
|
|
|
IsHost() bool
|
2020-10-22 16:54:50 +02:00
|
|
|
Connected() bool
|
2020-11-01 16:09:48 +01:00
|
|
|
Address() string
|
2020-10-22 16:54:50 +02:00
|
|
|
SetMuted(muted bool)
|
2020-10-31 21:46:29 +01:00
|
|
|
SetName(name string)
|
|
|
|
SetSocket(socket WebSocket)
|
|
|
|
SetPeer(peer Peer)
|
2020-11-01 21:03:25 +01:00
|
|
|
SetConnected(connected bool)
|
2020-11-01 16:09:48 +01:00
|
|
|
Disconnect(reason string) error
|
2020-10-22 16:54:50 +02:00
|
|
|
Send(v interface{}) error
|
|
|
|
SignalAnswer(sdp string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type SessionManager interface {
|
2020-11-01 20:23:09 +01:00
|
|
|
New(id string, admin bool) Session
|
2020-11-01 16:09:48 +01:00
|
|
|
Get(id string) (Session, bool)
|
|
|
|
Has(id string) bool
|
|
|
|
Destroy(id string) error
|
|
|
|
|
2020-10-22 16:54:50 +02:00
|
|
|
HasHost() bool
|
2020-11-01 16:09:48 +01:00
|
|
|
SetHost(host Session)
|
2020-10-31 23:53:19 +01:00
|
|
|
GetHost() Session
|
2020-10-22 16:54:50 +02:00
|
|
|
ClearHost()
|
2020-11-01 16:09:48 +01:00
|
|
|
|
|
|
|
Admins() []Session
|
|
|
|
Members() []Session
|
2020-10-22 16:54:50 +02:00
|
|
|
Broadcast(v interface{}, exclude interface{}) error
|
2020-11-01 16:09:48 +01:00
|
|
|
|
2020-10-31 23:03:37 +01:00
|
|
|
OnHost(listener func(session Session))
|
|
|
|
OnHostCleared(listener func(session Session))
|
|
|
|
OnCreated(listener func(session Session))
|
|
|
|
OnConnected(listener func(session Session))
|
2020-11-01 20:53:25 +01:00
|
|
|
OnDisconnected(listener func(session Session))
|
2020-11-01 18:39:12 +01:00
|
|
|
|
|
|
|
// auth
|
2020-11-01 20:23:09 +01:00
|
|
|
Authenticate(r *http.Request) (Session, error)
|
2020-10-22 16:54:50 +02:00
|
|
|
}
|