Main entry point into the share-state functionality.

This class opens a Websocket on the server to which clients can connect to and send ops via ShareDB to modify the shared state. The shared state validates the changes against the library schema, propagates them to the other connected clients and persists the state.

Constructors

Methods

Constructors

  • Parameters

    • httpServer: Server

      a http server that can be used to open the websocket

    • getLibraryMetadata: GetLibraryMetadataFunction

      return the library metadata (= library.json) for a library

    • getLibraryFileAsJson: GetLibraryFileAsJsonFunction

      return an arbitrary JSON file for a specific library; throw an error if the file doesn't exist or if it's not JSON

    • requestToUserCallback: RequestToUserFunction

      converts the request that is used to initiate the websocket connection to the user object for the user who is making the request; this is used to authenticate a user who connects to the websocket

    • getPermissionForUser: GetPermissionForUserFunction

      returns the permission a user has to a specific content object

    • getContentMetadata: GetContentMetadataFunction

      returns the metadata (h5p.json) for a piece of content

    • getContentParameters: GetContentParametersFunction

      returns the parameters (content.json) for a piece of content

    • Optionaloptions: { baseUrl?: string }

    Returns default

Methods

  • Call this method when a content object is deleted or changed in the host system. This will delete the state from the system (and also notify users who are currently connected)

    Parameters

    • contentId: string

    Returns Promise<void>