neko/internal/types/session.go

47 lines
1.1 KiB
Go
Raw Normal View History

package types
2020-11-02 06:39:12 +13:00
import "net/http"
type Session interface {
ID() string
Name() string
Admin() bool
IsHost() bool
Connected() bool
2020-11-01 09:46:29 +13:00
SetName(name string)
2020-11-26 06:36:33 +13:00
SetWebSocketPeer(websocket_peer WebSocketPeer)
2020-11-26 08:02:53 +13:00
SetWebSocketConnected(connected bool)
2020-11-26 06:41:40 +13:00
SetWebRTCPeer(webrtc_peer WebRTCPeer)
2020-11-26 08:02:53 +13:00
SetWebRTCConnected(connected bool)
// TODO: Refactor.
2020-11-02 09:03:25 +13:00
SetConnected(connected bool)
2020-11-02 04:09:48 +13:00
Disconnect(reason string) error
Send(v interface{}) error
SignalAnswer(sdp string) error
}
type SessionManager interface {
2020-11-02 08:23:09 +13:00
New(id string, admin bool) Session
2020-11-02 04:09:48 +13:00
Get(id string) (Session, 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
2020-11-19 08:30:33 +13:00
Broadcast(v interface{}, exclude interface{})
AdminBroadcast(v interface{}, exclude interface{})
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))
OnCreated(listener func(session Session))
OnConnected(listener func(session Session))
2020-11-02 08:53:25 +13:00
OnDisconnected(listener func(session Session))
2020-11-02 06:39:12 +13:00
// auth
2020-11-02 08:23:09 +13:00
Authenticate(r *http.Request) (Session, error)
}