npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spark-ar-participant-manager

v1.0.0

Published

Helper library help managing participants and provide utililties to deal with their updates.

Downloads

5

Readme

Spark AR Studio

Spark AR Studio

Participant Manager

Getting started

Spark AR project setup

You need AR Studio version to be >133 to use this library.

  1. Download Spark AR Studio.
  2. Open your project in Spark AR Studio.
  3. Open the AR Library from within the Assets panel and select the Script Packages tab.
  4. Search the "spark-ar-participant-manager" and import to the project.
  5. If you hasn't used multipeer and participants capability, please manually enable them.

Loading the module

To use it, import it via

import {createParticipantManager} from 'spark-ar-participant-manager';

And call in your main script body to initialise it

const participantManager = await createParticipantManager();

Documentation

activeParticipants: array<Participant>

activeParticipants contains all participants that are online and in same effect(include self), and stable sorted with their id.

Diagnostics.log(participantManager.activeParticipants.length)
Diagnostics.log(participantManager.activeParticipants[0].id)

Anytime a new active participant joined, no matter it's new participant joining the call or a participant joining the same effect, an event "join" will be emmited.

Anytime a active participant left, no matter it's leaving the call or opting out the same effect, an event "leave" will be emmited.

See Add event listener

currentHost: Participant

This returns an active participant as host, you can use it to check and only run certain logic only on host user. The host may change when activeParticipants changed, you can listen to "hostChange" event to know that.

(See Add event listener)

Diagnostics.log(participantManager.currentHost.id)

selfIndex: number

selfIndex provides the index of self in the activeParticipants

Diagnostics.log(participantManager.activeParticipants[participantManager.selfIndex].id === participantManager.self.id)

peerIndices: array<number>

peerIndices provides the index of each peer in the activeParticipants, if the peer is not active, the correspond array element value will be -1.

Here peer is the same order as Participants.getAllOtherParticipants

Add Event Listener

addListener(eventType: string, callback: Participant => void)

removeListener(eventType: string, callback: Participant => void)

You can add/remove event listener, the events are:

  • "join": when a new active participant joined
  • "leave": when an active participant left
  • "hostChange": when currentHost changed
function joinCallback(participant) {
  Diagnostics.log(participant.id)
}
participantManager.addListener('join', joinCallback)

// remove
participantManager.removeListener('join', joinCallback)

Participant Message Channel

getMessageChannel(topic: string): ParticipantMessageChannel

ParticipantMessageChannel provides a wrapper on multipeer message channel, that you can send message to specific participant.

You can call sendMessage(participantId: string, message: object, realTimeChannel: boolean): Promise<void> to send message to certain participant, only that participant will receive message. If provided null for the participantId, then it's a broadcast message like normal message channel.

You can call subscribeToMessage(callback: (from: string, message: object) => void) to subscribe to message. Example:

const secretChannel = participantManager.getMessageChannel('secret');
secretChannel.sendMessage(target.id, {text: 'Hello!'});

secretChannel.subscribeToMessage((from, message) => {
  Diagnostics.log("Receive from " + from + '\n says ' + message.text);
});

License

The Participant Manager library is MIT licensed.