Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebSocketProviderWithLocks

A class to provide Yjs synchronization over WebSocket.

The user can specify their own user-name and user-color by adding url parameters: ?username=Alice&usercolor=007007 where usercolor must be a six-digit hexadecimal encoded RGB value without the hash token.

We specify custom messages that the server can interpret. For reference please look in yjs_ws_server.

Hierarchy

  • WebsocketProvider
    • WebSocketProviderWithLocks

Implements

Index

Constructors

constructor

  • Construct a new WebSocketProviderWithLocks

    Parameters

    • options: IOptions

      The instantiation options for a WebSocketProviderWithLocks

    Returns WebSocketProviderWithLocks

Properties

_WS

_WS: { CLOSED: number; CLOSING: number; CONNECTING: number; OPEN: number; prototype: WebSocket }

Type declaration

  • Readonly CLOSED: number
  • Readonly CLOSING: number
  • Readonly CONNECTING: number
  • Readonly OPEN: number
  • prototype: WebSocket

_awarenessUpdateHandler

_awarenessUpdateHandler: (__namedParameters: any, origin: any) => void

Type declaration

    • (__namedParameters: any, origin: any): void
    • Parameters

      • __namedParameters: any
      • origin: any

      Returns void

_bcSubscriber

_bcSubscriber: (data: ArrayBuffer) => void

Type declaration

    • (data: ArrayBuffer): void
    • Parameters

      • data: ArrayBuffer

      Returns void

_beforeUnloadHandler

_beforeUnloadHandler: () => void

Type declaration

    • (): void
    • Returns void

_checkInterval

_checkInterval: any

Private _contentType

_contentType: any

Private _currentLockRequest

_currentLockRequest: any

Private _initialContentRequest

_initialContentRequest: any

Private _isInitialized

_isInitialized: any

_observers

_observers: Map<string, any>

Some desc.

Private _onConnectionStatus

_onConnectionStatus: any

Handle a change to the connection status.

param

The connection status.

Private _path

_path: any

_resyncInterval

_resyncInterval: number

Private _sendMessage

_sendMessage: any

Send a new message to WebSocket server.

param

The message to send

Private _serverUrl

_serverUrl: any

_synced

_synced: boolean

_updateHandler

_updateHandler: (update: Uint8Array, origin: any) => void

Type declaration

    • (update: Uint8Array, origin: any): void
    • Listens to Yjs updates and sends them to remote peers (ws and broadcastchannel)

      Parameters

      • update: Uint8Array
      • origin: any

      Returns void

awareness

awareness: Awareness

bcChannel

bcChannel: string

bcconnected

bcconnected: boolean

doc

doc: Doc

messageHandlers

messageHandlers: ((arg0: Encoder, arg1: Decoder, arg2: WebsocketProvider, arg3: boolean, arg4: number) => void)[]

mux

mux: mutex

roomname

roomname: string

shouldConnect

shouldConnect: boolean

Whether to connect to other peers or not

url

url: string

ws

ws: WebSocket

wsLastMessageReceived

wsLastMessageReceived: number

wsUnsuccessfulReconnects

wsUnsuccessfulReconnects: number

wsconnected

wsconnected: boolean

wsconnecting

wsconnecting: boolean

Accessors

synced

  • get synced(): boolean
  • set synced(arg: boolean): void
  • Returns boolean

  • Parameters

    • arg: boolean

    Returns void

Methods

acquireLock

  • acquireLock(): Promise<number>
  • Acquire a lock. Returns a Promise that resolves to the lock number.

    Returns Promise<number>

connect

  • connect(): void
  • Returns void

connectBc

  • connectBc(): void
  • Returns void

destroy

  • destroy(): void
  • Destroy the provider.

    Returns void

disconnect

  • disconnect(): void
  • Returns void

disconnectBc

  • disconnectBc(): void
  • Returns void

emit

  • emit(name: string, args: any[]): void
  • Emit a named event. All registered event listeners that listen to the specified name will receive the event.

    todo

    This should catch exceptions

    Parameters

    • name: string

      The event name.

    • args: any[]

      The arguments that are applied to the event listener.

    Returns void

off

  • off(name: string, f: Function): void
  • Parameters

    • name: string
    • f: Function

    Returns void

on

  • on(name: string, f: Function): void
  • Parameters

    • name: string
    • f: Function

    Returns void

once

  • once(name: string, f: Function): void
  • Parameters

    • name: string
    • f: Function

    Returns void

putInitializedState

  • putInitializedState(): void

releaseLock

  • releaseLock(lock: number): void
  • Release a lock.

    Parameters

    • lock: number

      The lock to release.

    Returns void

requestInitialContent

  • requestInitialContent(): Promise<boolean>
  • Resolves to true if the initial content has been initialized on the server. false otherwise.

    Returns Promise<boolean>

setPath

  • setPath(newPath: string): void
  • This should be called by the docregistry when the file has been renamed to update the websocket connection url

    Parameters

    • newPath: string

    Returns void

Generated using TypeDoc