Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

video-call-client

Package Overview
Dependencies
Maintainers
6
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

video-call-client

Javascript client for siosLIFE Video Call server.

  • 2.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

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.

Keywords

FAQs

Package last updated on 12 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc