nttcom / SkyWay-MultiParty

[Deprecated] This is a library for easy implementation of group video chat.
18 stars 15 forks source link

日本語 | English

Deprecated!

We have released a new WebRTC platform, ECLWebRTC, to take the place of SkyWay. We will be shutting down the SkyWay servers in March 2018. Customers who are currently using SkyWay are required to migrate to ECLWebRTC by then or their services will stop working.

If you are looking for the repository of ECLWebRTC, please use MeshRoom class and SFURoom Class.

SkyWay MultiParty

This is a library for easy implementation of group video chat with SkyWay(http://nttcom.github.io/skyway/).

Sample

// Generate a MultiParty instance.
multiparty = new MultiParty( {
  "key": "********-****-****-****-************"  /* SkyWay key */,
  "reliable": true /* Use reliable communication(SCTP) in Data Channel. */
});

// for MediaStream
//

multiparty.on('my_ms', function(video) {
  // Show my video.
  var vNode = MultiParty.util.createVideoNode(video);
  vNode.volume = 0;
  $(vNode).appendTo("#streams");
}).on('peer_ms', function(video) {
  // Show peer's video.
  var vNode = MultiParty.util.createVideoNode(video);
  $(vNode).appendTo("#streams");
}).on('ms_close', function(peer_id) {
  // Remove the video node when peer is disconnected.
  $("#"+peer_id).remove();
})

// for DataChannel
//

$("button").on('click', function(ev) {
  multiparty.send('hello'); /* Send message to the connected peers. */
});

multiparty.on('message', function(mesg) {
  $("p.receive").append(mesg.data + "<br>"); /* Show the received message.  */
});

// Connect to the server and peers
multiparty.start()

Demo page(local test)

  1. update your own APIKEY in line 57 of examples/multiparty-sample.html. (Please be sure that localhost is registered in your APIKEY setting)
  2. $ npm install
  3. $ npm run webpack-dev-server
  4. open https://localhost:8081/examples/multiparty-sample.html in two browser window.

In case you don't have APIKEY, please sign-up SkyWay account and obtain API key at https://skyway.io/ds/.

Demo Page

Installing with NPM

$ npm install skyway-multiparty

Using with webpack etc.

const MultiParty = require('skyway-multiparty')

Download

API reference

MultiParty

var multiparty = new MultiParty([options]);

start

Connect to the SkyWay server and all peers.

multiparty.on

multiparty.on(event, callback);

'open'

multiparty.on('open', function(myid){ ... });

'my_ms'

multiparty.on('my_ms', function({"src": <object url>, "id": <myid>}){...});

'peer_ms'

multiparty.on('peer_ms', function({"src": <object url>, "id": <peer-id>, "reconnect": <true or false>}){ ... });

'peer_ss'

multiparty.on('peer_ss', function({"src": <object url>, "id": <peer-id>, "reconnect": <true or false>}){ ... });

'ms_close'

multiparty.on('ms_close', function(peer-id){ ... });

'ss_close'

multiparty.on('ss_close', function(peer-id){ ... });

'dc_open'

multiparty.on('dc_open', function(peer-id){ ... });

'message'

multiparty.on('message', function({"id": <peer-id>, "data": <data>}){ ... });

'dc_close'

multiparty.on('dc_close', function(peer-id){ ... });

'error'

multiparty.on('error', function(error){ ... });

mute

Mute current video/audio.

multiparty.mute({"video": <true of false>, "audio": <true or false>);

unmute

Unmute current video/audio.

multiparty.unmute({"video": <true of false>, "audio": <true or false>);

removePeer

Close peer's media stream and data stream.

multiparty.removePeer(peer-id);

send

Send data to every peer.

multiparty.send(data);

close

Close every connection.

multiparty.close();

startScreenShare

Start screen share.

multiparty.startScreenShare(function(stream){
  // success callback
}, function(err) {
  // error callback
});

stopScreenShare

Stop screen share.

multiparty.stopScreenShare();

listAllPeers

Get all of the connected peer ids.

multiparty.listAllPeers(function(lists) { ... });

reconnect

Reconnect the disconnected peer.

multiparty.reconnect(peer_id, function({"video": <boolean>, "screen": <boolean>, "data": <boolean>}){ ... });

MultiParty.util.createVideoNode

Create video node from Object URL.

var vNode = MultiParty.util.createVideoNode({"src": object_url, "id": peer_id}){ ... });

LICENSE & Copyright

LICENSE