add sessions cursors.

This commit is contained in:
Miroslav Šedivý
2021-10-24 01:09:41 +02:00
parent 318b833b30
commit 0b5e064cab
7 changed files with 97 additions and 29 deletions

View File

@ -21,6 +21,7 @@ const (
SESSION_DELETED = "session/deleted"
SESSION_PROFILE = "session/profile"
SESSION_STATE = "session/state"
SESSION_CURSORS = "session/cursors"
)
const (

View File

@ -87,6 +87,12 @@ type SessionData struct {
State types.SessionState `json:"state"`
}
type SessionCursor struct {
ID string `json:"id"`
X uint16 `json:"x"`
Y uint16 `json:"y"`
}
/////////////////////////////
// Control
/////////////////////////////

View File

@ -12,6 +12,11 @@ var (
ErrSessionLoginDisabled = errors.New("session login disabled")
)
type Cursor struct {
X int
Y int
}
type SessionState struct {
IsConnected bool `json:"is_connected"`
IsWatching bool `json:"is_watching"`
@ -23,8 +28,8 @@ type Session interface {
State() SessionState
IsHost() bool
// cursor position
SetPosition(x, y int)
// cursor
SetCursor(x, y int)
// websocket
SetWebSocketPeer(websocketPeer WebSocketPeer)
@ -50,6 +55,9 @@ type SessionManager interface {
GetHost() Session
ClearHost()
SetCursor(x, y int, session Session)
PopCursors() map[Session]Cursor
Broadcast(event string, payload interface{}, exclude interface{})
AdminBroadcast(event string, payload interface{}, exclude interface{})