2020-10-23 03:54:50 +13:00
|
|
|
package types
|
|
|
|
|
2020-11-02 06:39:12 +13:00
|
|
|
import "net/http"
|
|
|
|
|
2020-11-26 10:07:05 +13:00
|
|
|
type MemberProfile struct {
|
2020-12-03 05:29:38 +13:00
|
|
|
Secret string
|
|
|
|
Name string
|
|
|
|
|
|
|
|
IsAdmin bool
|
|
|
|
CanLogin bool
|
|
|
|
CanConnect bool
|
|
|
|
CanWatch bool
|
|
|
|
CanHost bool
|
|
|
|
CanAccessClipboard bool
|
2020-11-26 10:07:05 +13:00
|
|
|
}
|
|
|
|
|
2020-10-23 03:54:50 +13:00
|
|
|
type Session interface {
|
|
|
|
ID() string
|
2020-12-03 05:29:38 +13:00
|
|
|
|
|
|
|
VerifySecret(secret string) bool
|
2020-10-23 03:54:50 +13:00
|
|
|
Name() string
|
2020-12-03 04:49:51 +13:00
|
|
|
IsAdmin() bool
|
2020-12-03 05:29:38 +13:00
|
|
|
CanLogin() bool
|
|
|
|
CanConnect() bool
|
|
|
|
CanWatch() bool
|
|
|
|
CanHost() bool
|
|
|
|
CanAccessClipboard() bool
|
|
|
|
SetProfile(profile MemberProfile)
|
|
|
|
|
2020-11-01 09:20:42 +13:00
|
|
|
IsHost() bool
|
2020-12-03 04:49:51 +13:00
|
|
|
IsConnected() bool
|
2020-12-03 05:29:38 +13:00
|
|
|
IsReceiving() bool
|
|
|
|
Disconnect(reason string) error
|
|
|
|
|
2020-11-26 06:36:33 +13:00
|
|
|
SetWebSocketPeer(websocket_peer WebSocketPeer)
|
2020-11-26 08:02:53 +13:00
|
|
|
SetWebSocketConnected(connected bool)
|
2020-12-03 05:29:38 +13:00
|
|
|
Send(v interface{}) error
|
|
|
|
|
2020-11-26 06:41:40 +13:00
|
|
|
SetWebRTCPeer(webrtc_peer WebRTCPeer)
|
2020-11-26 08:02:53 +13:00
|
|
|
SetWebRTCConnected(connected bool)
|
2020-10-23 03:54:50 +13:00
|
|
|
SignalAnswer(sdp string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type SessionManager interface {
|
2020-11-28 07:59:54 +13:00
|
|
|
Create(id string, profile MemberProfile) Session
|
2020-11-02 04:09:48 +13:00
|
|
|
Get(id string) (Session, bool)
|
2020-11-26 10:06:13 +13:00
|
|
|
Delete(id string) error
|
2020-11-02 04:09:48 +13:00
|
|
|
|
2020-10-23 03:54:50 +13:00
|
|
|
HasHost() bool
|
2020-11-02 04:09:48 +13:00
|
|
|
SetHost(host Session)
|
2020-11-01 11:53:19 +13:00
|
|
|
GetHost() Session
|
2020-10-23 03:54:50 +13:00
|
|
|
ClearHost()
|
2020-11-02 04:09:48 +13:00
|
|
|
|
2020-12-03 05:36:06 +13:00
|
|
|
HasConnectedMembers() bool
|
2020-11-02 04:09:48 +13:00
|
|
|
Members() []Session
|
2020-11-19 08:30:33 +13:00
|
|
|
Broadcast(v interface{}, exclude interface{})
|
2020-11-19 09:34:39 +13:00
|
|
|
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))
|
2020-12-03 06:59:32 +13:00
|
|
|
OnCreated(listener func(session Session))
|
|
|
|
OnDeleted(listener func(session Session))
|
2020-11-01 11:03:37 +13:00
|
|
|
OnConnected(listener func(session Session))
|
2020-11-02 08:53:25 +13:00
|
|
|
OnDisconnected(listener func(session Session))
|
2020-12-03 06:59:32 +13:00
|
|
|
OnReceivingStarted(listener func(session Session))
|
|
|
|
OnReceivingStopped(listener func(session Session))
|
|
|
|
OnProfileUpdated(listener func(session Session))
|
2020-12-03 05:29:38 +13:00
|
|
|
|
2020-12-02 23:24:20 +13:00
|
|
|
ImplicitHosting() bool
|
2020-11-02 06:39:12 +13:00
|
|
|
|
2020-11-02 08:23:09 +13:00
|
|
|
Authenticate(r *http.Request) (Session, error)
|
2020-10-23 03:54:50 +13:00
|
|
|
}
|