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

video-call-client

v2.3.1

Published

Javascript client for siosLIFE Video Call server.

Downloads

29

Readme

video-call-client

Javascript client for siosLIFE's Video Call server.

Usage

var VideoCallClient = require('video-call-client');

Initializing the client

The first thing you need to do is create a client using VideoCallClient.

var videoCallClient = VideoCallClient(serverUrl, iceConfig, constraints);

The iceConfig object is a RTCConfiguration object used to create the RTCPeerConnection.

The constraints is a MediaStreamConstraints object passed to getUserMedia.

Connecting to the server

As a normal user

You can connect to the Video Call server by using the login method of the video call client.

When the connection is established a connected event will be emitted to notify that the client is ready to start and receive calls.

videoCallClient.login({ user: ..., families: ... });

videoCallClient.on('connected', function() {
  // let's see who's online
  console.log(videoCallClient.users);
});

The object passed to login will be sent to the Video Call server, so more properties can be sent if needed.

As a userless machine

A machine can connect to the server to receive calls even if no users is logged in.

To do this, the machineLogin method can be used:

videoCallClient.machineLogin({ institutionId: ..., machineId: ... });

videoCallClient.on('connected', function() {
  // Will now start receiving calls
});

Like with login, a connected event will be emitted when the connection is established and the client is ready to receive calls.

A client logged as a machine user cannot start calls.

Starting calls

A call can be started with VideoCallClient's .startCall() method. This method receives the target user's ID and returns an OutgoingCall object.

If the target user accepts the call, the OutgoingCall will emit an accepted event with a Call object.

If the call gets rejected, either by the user of if the user is unavailable, a rejected event will be emitted with the reason why the call was rejected.

var outgoingCall = videoCallClient.startCall(userId, institutionId);

outgoingCall.on('accepted', function(call) {
  // your call was accepted
});

outgoingCall.on('rejected', function(reason) {
  // too bad, you've been rejected
});

Receiving calls

When someone calls you VideoCallClient will emit a call event.

This event's callback will receive an IncomingCall object to .accept() or .reject() the call.

The IncomingCall's .accept() method will return a Call object.

videoCallClient.on('call', function(incomingCall) {
  // accept the call
  var call = incomingCall.accept();

  // or reject it
  incomingCall.reject();

  // but don't forget that the calling user can give up on you
  incomingCall.on('end', function() {
    // too late
  });
});

Ending calls

When a call is established, you can use the Call object to end the call.

It will also emit an end event if the other user ends the call on their side.

// lets end this
call.terminate();

// before someone else does
call.on('end', function() {
  // bye bye
});

Viewing online users

The VideoCallClient object has a users property. This is an array of all the users that are online in the same room.

When a users joins or leaves the room, a user-joined and a user-left event will be emitted, respectively.

videoCallClient.users.forEach(function(user) {
  console.log(user);
});

videoCallClient.on('user-joined', function(user) {
  // new user
});

videoCallClient.on('user-left', function(user) {
  // this one left the room
});

A user only has a userId and a type.