v0.0.X

JS client description

If you want to use nextrtc js client you have to add to your code following js files:
– adapter.js
– nextRTC.js
Both files are available in project nextrtc-signaling-server in directory resources. Adapter is taken from here, so if you want to use newest version you should take it direct from that project.


 

NextRTC js client constructor requires:

  • wsURL which should points to your endpoint
    {ws/wss}://{host}:{port}/{applicationName}/{endpointGivenInAnnotation}

    endpointGivenInAnnotation e.g. – @ServerEndpoint(value = “/signaling” …)

  • mediaConfig – are passed straight to adapter, so more information about parametres you can find in webrtc/adapter documentation
  • peerConfig – are also described in webrtc/adapter project

Example is shown below and it’s also available in videochat-example

new NextRTC({
	wsURL : 'wss://examples.nextrtc.org/videochat/signaling',
	mediaConfig : {
		video : true,
		audio : true,
	},
	peerConfig : {
		'iceServers' : [ {
			url : "stun:stun.l.google.com:19302"
			} ]
		},
	});

 

How to use nextrtc on static page?

When page will be fully loaded you should create nextrtc object.
If you don’t know when your page is fully loaded you can use override method NextRTC.onReady (this way of use is presented in example).

When you create NextRTC object you have to provide function which will be called when event happens.
To register function you have to call method on() as presented in snipped:

var nextRTC = new NextRTC({
...
});

nextRTC.on('{eventName}', function(nextrtc:NextRTC, event:Event){

});

There are two signals which are providing other second parameter type. Those signals are:
localStream and remoteStream, when you are handling local audio/video stream and incomming audio/video stream you can simply attach stream to valid element (without additional action like resolving stream by description provided in event).

nextRTC.on('{localStream|remoteStream}', function(nextrtc:NextRTC, stream:Stream){

});

 

Event structure is presented below:

{
"signal":"<supported signal>", // here is the name of signal on which you are reacting, or signal which you want to post
"from":"", // unique ID of user
"to":"", // unique ID of user
"content":"", // spd's id it depends on signal (possible contents are described in ...)
"custom":{} // map where you can add your own data
}

Event is serialized java version of message.

Leave a Reply