session

package
v1.6.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const WS_DELAYED_DURATION = 5 * time.Second

client is expected to reconnect within 5 second if some unexpected websocket disconnect happens

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionCtx

type SessionCtx struct {
	// contains filtered or unexported fields
}

func (*SessionCtx) ConnectWebSocketPeer added in v1.6.11

func (session *SessionCtx) ConnectWebSocketPeer(websocketPeer types.WebSocketPeer)

Connect WebSocket peer sets current peer and emits connected event. It also destroys the previous peer, if there was one. If the peer is already set, it will be ignored.

func (*SessionCtx) DestroyWebSocketPeer added in v1.6.11

func (session *SessionCtx) DestroyWebSocketPeer(reason string)

Destroy WebSocket peer disconnects the peer and destroys it. It ensures that the peer is disconnected immediately even though normal flow would be to disconnect it delayed.

func (*SessionCtx) DisconnectWebSocketPeer added in v1.6.11

func (session *SessionCtx) DisconnectWebSocketPeer(websocketPeer types.WebSocketPeer, delayed bool)

Disconnect WebSocket peer sets current peer to nil and emits disconnected event. It also allows for a delayed disconnect. That means, the peer will not be disconnected immediately, but after a delay. If the peer is connected again before the delay, the disconnect will be cancelled.

If the peer is not the current peer or the peer is nil, it will be ignored.

func (*SessionCtx) GetWebRTCPeer

func (session *SessionCtx) GetWebRTCPeer() types.WebRTCPeer

Get current WebRTC peer. Nil if not connected.

func (*SessionCtx) ID

func (session *SessionCtx) ID() string

func (*SessionCtx) IsHost

func (session *SessionCtx) IsHost() bool

func (*SessionCtx) PrivateModeEnabled

func (session *SessionCtx) PrivateModeEnabled() bool

func (*SessionCtx) Profile

func (session *SessionCtx) Profile() types.MemberProfile

func (*SessionCtx) Send

func (session *SessionCtx) Send(event string, payload any)

Send event to websocket peer.

func (*SessionCtx) SetCursor

func (session *SessionCtx) SetCursor(cursor types.Cursor)

func (*SessionCtx) SetWebRTCConnected

func (session *SessionCtx) SetWebRTCConnected(webrtcPeer types.WebRTCPeer, connected bool)

Set if current webrtc peer is connected or not. Since there might be lefover calls from webrtc peer, that are not used anymore, we need to check if the webrtc peer is still the same as the one we are setting the connected state for.

If webrtc peer is disconnected, we don't expect it to be reconnected, so we set it to nil and send a signal close to the client. New connection is expected to use a new webrtc peer.

func (*SessionCtx) SetWebRTCPeer

func (session *SessionCtx) SetWebRTCPeer(webrtcPeer types.WebRTCPeer)

Set webrtc peer and destroy the old one, if there is old one.

func (*SessionCtx) State

func (session *SessionCtx) State() types.SessionState

type SessionManagerCtx

type SessionManagerCtx struct {
	// contains filtered or unexported fields
}

func New

func New(config *config.Session) *SessionManagerCtx

func (*SessionManagerCtx) AdminBroadcast

func (manager *SessionManagerCtx) AdminBroadcast(event string, payload any, exclude ...string)

func (*SessionManagerCtx) Authenticate

func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session, error)

func (*SessionManagerCtx) Broadcast

func (manager *SessionManagerCtx) Broadcast(event string, payload any, exclude ...string)

func (*SessionManagerCtx) ClearHost

func (manager *SessionManagerCtx) ClearHost()

func (*SessionManagerCtx) CookieClearToken

func (manager *SessionManagerCtx) CookieClearToken(w http.ResponseWriter, r *http.Request)

func (*SessionManagerCtx) CookieEnabled

func (manager *SessionManagerCtx) CookieEnabled() bool

func (*SessionManagerCtx) CookieSetToken

func (manager *SessionManagerCtx) CookieSetToken(w http.ResponseWriter, token string)

func (*SessionManagerCtx) Create

func (manager *SessionManagerCtx) Create(id string, profile types.MemberProfile) (types.Session, string, error)

func (*SessionManagerCtx) Delete

func (manager *SessionManagerCtx) Delete(id string) error

func (*SessionManagerCtx) Get

func (manager *SessionManagerCtx) Get(id string) (types.Session, bool)

func (*SessionManagerCtx) GetByToken

func (manager *SessionManagerCtx) GetByToken(token string) (types.Session, bool)

func (*SessionManagerCtx) GetHost

func (manager *SessionManagerCtx) GetHost() (types.Session, bool)

func (*SessionManagerCtx) InactiveCursorsBroadcast

func (manager *SessionManagerCtx) InactiveCursorsBroadcast(event string, payload any, exclude ...string)

func (*SessionManagerCtx) List

func (manager *SessionManagerCtx) List() []types.Session

func (*SessionManagerCtx) OnConnected

func (manager *SessionManagerCtx) OnConnected(listener func(session types.Session))

func (*SessionManagerCtx) OnCreated

func (manager *SessionManagerCtx) OnCreated(listener func(session types.Session))

func (*SessionManagerCtx) OnDeleted

func (manager *SessionManagerCtx) OnDeleted(listener func(session types.Session))

func (*SessionManagerCtx) OnDisconnected

func (manager *SessionManagerCtx) OnDisconnected(listener func(session types.Session))

func (*SessionManagerCtx) OnHostChanged

func (manager *SessionManagerCtx) OnHostChanged(listener func(session types.Session))

func (*SessionManagerCtx) OnProfileChanged

func (manager *SessionManagerCtx) OnProfileChanged(listener func(session types.Session))

func (*SessionManagerCtx) OnSettingsChanged

func (manager *SessionManagerCtx) OnSettingsChanged(listener func(new types.Settings, old types.Settings))

func (*SessionManagerCtx) OnStateChanged

func (manager *SessionManagerCtx) OnStateChanged(listener func(session types.Session))

func (*SessionManagerCtx) PopCursors

func (manager *SessionManagerCtx) PopCursors() map[types.Session][]types.Cursor

func (*SessionManagerCtx) SetCursor

func (manager *SessionManagerCtx) SetCursor(cursor types.Cursor, session types.Session)

func (*SessionManagerCtx) SetHost

func (manager *SessionManagerCtx) SetHost(host types.Session)

func (*SessionManagerCtx) Settings

func (manager *SessionManagerCtx) Settings() types.Settings

func (*SessionManagerCtx) Update

func (manager *SessionManagerCtx) Update(id string, profile types.MemberProfile) error

func (*SessionManagerCtx) UpdateSettings

func (manager *SessionManagerCtx) UpdateSettings(new types.Settings)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL