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.
The multipeer debugging tool can be used to simulate message streams and debug multipeer effects.
Follow the Scripting Your First Multipeer Effect article to build an effect using the MultipeerModule
API.
//============================================================================ // 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]
This module exposes no properties.
Method | Description |
---|---|
getBinaryMessageChannel | getBinaryMessageChannel(topic: string): BinaryMessageChannel Returns the specified BinaryMessageChannel .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. |
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. |
Class | Description |
---|---|
BinaryMessageChannel | Represents a named bidirectional communication channel, which allows you to send messages containing a Uint8Array between peers.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 an effect. |
MessageChannel | Represents a named bidirectional communication channel. 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 an effect. |