Broadcast Messages Between Client Apps

JavaScript web application demonstrating how-to use CommandService to broadcast information to other clients in a conference such as a dynamic position on screen.

13641364

Coordinating position on screen across clients

Overview

Users can use arrow keys to move their avatar around the screen. Position of avatar is communicated to other users in real time utilizing Dolby.io Communications API's CommandService.

Features Tech Stack
  • JavaScript

Getting Started

Key concepts

To send a command to all participants in a session, call the send() method of the Command object.

VoxeetSDK.command
  .send({payload: 'hello world'})
  .catch((err) => {
    console.error(err);
  });

To receive commands send in a session, add an event listener for the 'received' event dispatched by the Command object.

VoxeetSDK.command.on('received', (participant, message) => {
  const dataParsed = JSON.parse(message);
  console.log("Command received, message:", dataParsed.payload)
}

❗️

Initial State

Messages sent with the CommandService are non-durable and not persistent meaning that inactive participants who have not yet joined the conference will not receive messages sent prior to joining the session.

Demo

620620

Did this page help you?