client

Namespace

client

Description:
  • Client-side part of the soundworks framework.

    A soundworks client can run seamlessly in a browser or in a Node.js runtime.

    import '@soundworks/helpers/polyfills.js';
    import { Client } from '@soundworks/core/client.js';
    import launcher from '@soundworks/helpers/launcher.js';
    
    // - General documentation: https://soundworks.dev/
    // - API documentation:     https://soundworks.dev/api
    // - Issue Tracker:         https://github.com/collective-soundworks/soundworks/issues
    // - Wizard & Tools:        `npx soundworks`
    
    const config = window.SOUNDWORKS_CONFIG;
    
    async function main($container) {
      try {
        const client = new Client(config);
    
        // client.pluginManager.register(pluginName, pluginFactory, {options}, [dependencies])
    
        launcher.register(client, {
          initScreensContainer: $container,
          reloadOnVisibilityChange: false,
        });
    
        await client.start();
    
        $container.innerText = `client ${client.id} started`);
    
      } catch(err) {
        console.error(err);
      }
    }
    
    launcher.execute(main);
    
Source:

Classes

Client
Context
ContextManager
Plugin
PluginManager
SharedState
SharedStateCollection
Socket
StateManager

Type Definitions

ClientConfig

Description:
  • Configuration object for a client running in a browser runtime.

Source:
Properties:
Name Type Attributes Description
role string

Role of the client in the application (e.g. 'player', 'controller').

app object <optional>

Application configration object.

Properties
Name Type Attributes Default Description
name string <optional>
''

Name of the application.

author string <optional>
''

Name of the author.

env object <optional>

Environment configration object.

Properties
Name Type Attributes Default Description
useHttps boolean

Define if the websocket should use secure connection.

serverAddress boolean <optional>
''

Address the socket server. Mandatory for node clients. For browser clients, use window.location.domain as fallback if empty.

port boolean

Port of the socket server.

websockets string <optional>
{}

Configuration options for websockets.

subpath string <optional>
''

If running behind a proxy, path to the application.

Configuration object for a client running in a browser runtime.

Type:
  • object