MultipeerModule Overview
MultipeerModule Overview
MultipeerModule Overview

MultipeerModule

Allows an effect running in a video call to communicate with other instances of the same effect within the video call.

Multipeer communication is based around the broadcasting and receiving of JSON formatted messages on message channels.

Messages are broadcast to all peers except the instance that the message was broadcast from - an effect can’t broadcast a message to itself.

You can use the multipeer debugging tool to simulate message streams and debug multipeer effects.

//============================================================================
// Retrieves a message channel and sends a message on it.
//
//
// Required project capabilities:
// - Multipeer (auto added on Multipeer module import)
//
//============================================================================

// Load in the required modules
const Multipeer = require('Multipeer');
 
(async function () {  // Enables async/await in JS [part 1]
 
  // Retrieve the 'MyTopic' message channel   
  const topicChannel = Multipeer.getMessageChannel("MyTopic");

  // Send a message on the 'MyTopic' channel
  topicChannel.sendMessage({
    "message": "Hello  MyTopic channel!",
    "someValue": 10,
    "someBoolean": true
  });

})(); // Enables async/await in JS [part 2]
      

Properties

This module exposes no properties.

Methods

MethodDescription
getMessageChannel
getMessageChannel(topic: string): MessageChannel


Returns the specified MessageChannel.

If no channel with the specified name is found, the GLOBAL channel is used by default.

* topic - the name of the message channel (topic) to retrieve.

Classes

ClassDescription
MessageChannelA named, bidirectional channel for communication.

Message channels are created on demand and persist for the duration of the effect's lifetime.

Channels are available to all participants active within the same instance of a given effect.

Was this article helpful?