Node.js client that implements a subset of the WebSocket interface of the Janus WebRTC Gateway.
Note: For now it supports the videoroom plugin only.
varJanusClient=require('janus-videoroom-client').Janus;Without authentication
varclient=newJanusClient({url: 'ws://localhost:8188'});Token based authentication
varclient=newJanusClient({url: 'ws://localhost:8188',token: 'yourToken'});Static secret authentication
varclient=newJanusClient({url: 'ws://localhost:8188',apiSecret: 'yourStaticSecret'});client.onConnected(()=>{client.createSession().then((session)=>{
...
}).catch((err)=>{
...
})});client.onDisconnected(()=>{});client.onError((err)=>{});client.connect();client.createSession().then((session)=>{
...
});client.createSession().then((session)=>{returnsession.videoRoom().createVideoRoomHandle();}).then((videoRoomHandle)=>{
...
});client.createSession().then((session)=>{returnsession.videoRoom().defaultHandle();}).then((videoRoomHandle)=>{
...
});videoRoomHandle.create({publishers: 3,is_private: 'no',secret: '****',pin: '****',audiocodec: 'opus',videocodec: 'vp8',record: false}).then((result)=>{varroomId=result.room;
...
});session.videoRoom().publishFeed(room,offerSdp).then((publisherHandle)=>{varanswerSdp=publisherHandle.getAnswer();
...
});publisherHandle.trickle(candidate).then(()=>{
...
});session.videoRoom().listenFeed(room,feed).then((listenerHandle)=>{varofferSdp=listenerHandle.getOffer();
...
});listenerHandle.trickle(candidate).then(()=>{
...
});listenerHandle.setRemoteAnswer(answerSdp).then(()=>{
...
});session.videoRoom().getFeeds(room).then((feeds)=>{for(letfeedoffeeds){
...
}});npm test