Kurento datachannel creation and management - javascript

I'm developing a WebRTC application based in node.js and Kurento and I want to implement a chat using datachannels.
I've seen the browser javascript version and I want to integrate it in the one to one node.js example.
What I have done
1.- I've created both WebRTCEndpoints with datachannel capabilities like this: pipeline.create('WebRtcEndpoint', {useDataChannels: true}, function(error, calleeWebRtcEndpoint) {...}
2.- Then I've created a <textarea> with a <button> to send messages, and a <div> to view them.
So my question is, what servers I have to put when I create the datachannel in the client? This snippet is from the browser javascript datachannel tutorial but at the start of the file we can clearly see ICE servers are ignoring in the connection creation. Also, I don’t know how you manage them in the node.js tutorials, so I'm a bit lost here.
peerConnection = new RTCPeerConnection(servers, configuration);
channel = peerConnection.createDataChannel(getChannelName(), dataConstraints);
channel.onopen = onSendChannelStateChange;
channel.onclose = onSendChannelStateChange;
channel.onmessage = onMessage;`
Thanks for the help.

I've discovered what was I doing wrong and now the I can send messages by datachannels.
Basically what I've done is to add peerConnection option to the options object. Next that option object is passed to WebRtcPeerSendrecv connection method and it's done!
var options = {
peerConnection: peerConnection, //Must be passed as a field in options to make DataChannels work
localVideo : videoInput,
remoteVideo : videoOutput,
onicecandidate : onIceCandidate
}
webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(){...});

Related

How to send Camera Stream from Unity to the web browser?

I am trying to connect a unity client to a browser client using Webrtc. This step is complete the two clients are now connected (Signaling is complete). What I need to do next is to send the video stream from the c# Camera object to the other peer (browser). Here's what have done which is not working and I do not know why?
The c# code :
var track = arCamera.CaptureStreamTrack(1280, 720, 3000);
localConnection.AddTrack(track);
Then I register the ontrack event for the RTCPeerConnection Object
The javascript code:
function handleTrack (e) {
console.log("Recieved a Track");
remotePeerVideo.current.srcObject = e.streams[0];
}
When I
console.log(e.streams); this is the result:
[MediaStream]
0:{active: true, id: "9322aaa7-69b6-4ef4-8f49-c457ef4ffd16"}
I add this track to the srcObj of a video element, but it does not work. Any Ideas what might be wrong or if there is another way to get the video stream from the c# Camera Object?

Enable users of a WebRtc app to download webrtc logs via javascript

I've seen the following:
chrome://webrtc-internals
However I'm looking for a way to let users click a button from within the web app to either download or - preferably - POST WebRtc logs to an endpoint baked into the app. The idea is that I can enable non-technical users to share technical logs with me through the click of a UI button.
How can this be achieved?
Note: This should not be dependent on Chrome; Chromium will also be used as the app will be wrapped up in Electron.
You need to write a javascript equivalent that captures all RTCPeerConnection API calls. rtcstats.js does that but sends all data to a server. If you replace that behaviour with storing it in memory you should be good.
This is what I ended up using (replace knockout with underscore or whatever):
connectionReport.signalingState = connection.signalingState;
connectionReport.stats = [];
connection.getStats(function (stats) {
const reportCollection = stats.result();
ko.utils.arrayForEach(reportCollection, function (innerReport) {
const statReport = {};
statReport.id = innerReport.id;
statReport.type = innerReport.type;
const keys = innerReport.names();
ko.utils.arrayForEach(keys, function (reportKey) {
statReport[reportKey] = innerReport.stat(reportKey);
})
connectionReport.stats.push(statReport);
});
connectionStats.push(connectionReport);
});
UPDATE:
It appears that this getStats mechanism is soon-to-be-deprecated.
Reading through js source of chrome://webrtc-internals, I noticed that the web page is using a method called chrome.send() to send messages like chrome.send('enableEventLogRecordings');, to execute logging commands.
According to here:
chrome.send() is a private function only available to internal chrome
pages.
so the function is sandboxed which makes accessing to it not possible

How can I send push notification from javascript or c# to android - IOS and WinPhone

I implement push notification using this totarial. Now I want to send a notification from a website using server C# code or simply with a javascript code but the following link only implement sending notification using node:
var gcm = require('node-gcm');
var message = new gcm.Message();
//API Server Key
var sender = new gcm.Sender('AIzaSyCDx8v9R0fMsAsjoAffF-P3FCFWXlvwLhg');
var registrationIds = [];
// Value the payload data to send...
message.addData('message',"\u270C Peace, Love \u2764 and PhoneGap \u2706!");
message.addData('title','Push Notification Sample' );
message.addData('msgcnt','3'); // Shows up in the notification in the status bar
message.addData('soundname','beep.wav'); //Sound to play upon notification receipt - put in the www folder in app
//message.collapseKey = 'demo';
//message.delayWhileIdle = true; //Default is false
message.timeToLive = 3000;// Duration in seconds to hold in GCM and retry before timing out. Default 4 weeks (2,419,200 seconds) if not specified.
// At least one reg id required
registrationIds.push('APA91bwu-47V0L7xB55zoVd47zOJahUgBFFuxDiUBjLAUdpuWwEcLd3FvbcNTPKTSnDZwjN384qTyfWW2KAJJW7ArZ-QVPExnxWK91Pc-uTzFdFaJ3URK470WmTl5R1zL0Vloru1B-AfHO6QFFg47O4Cnv6yBOWEFcvZlHDBY8YaDc4UeKUe7ao');
/**
* Parameters: message-literal, registrationIds-array, No. of retries, callback-function
*/
sender.send(message, registrationIds, 4, function (result) {
console.log(result);
});
I want to send notification automatically using website or something like this (I want to scheduling sending notification in some times for remind drug time to patient).
In addition, I found this : pubnub for sending notification but unfortunately, it's not work correctly. Pubnub demo doesn't work.
How can I do this? Please help me.
Can you give either of these a try if you're writing C# on the server side? :)
Azure Notification Hub
PushSharp
Personally I'd write a Windows Service that runs a loop to poll the database for any notifications it needs to send out, sends it to Azure Notification Hub or AWS Push Notifications, sleeps for awhile, and then repeats the process.
You don't want to do it on the client side of a web page because the only way the code could ever run is if you had a web browser open all the time pointing to the page.

Trouble during passing extension data along with session request in QuickBlox

I am working on a project which provides video calling from web to phone (iOS or Android). I am using QuickBlox + WebRTC to implement video calling. From web I want to pass some additional info along with call request like caller name, etc. I looked into the JavaScript documentation of QuickBlox + WebRTC which suggest to use the following code (JavaScript):
var array = {
me: "Hari Gangadharan",
}
QB.webrtc.call(callee.id, 'video', array);
I have implemented the same code but unable to get the info attached with session request on the receiver side (getting nil reference in iOS method).
- (void)didReceiveNewSession:(QBRTCSession *)session userInfo:(NSDictionary *)userInfo {
//Here userInfo is always nil
}
Please use the following structure
var array = {
"userInfo": {
"me":"Hari Gangadharan",
}
}
because our iOS SDK uses "userInfo" as a key for parsing custom user info
Check Signaling v1.0

websocket php vs node js

Could somebody say what are the differences between "websocket php" http://www.php.net/manual/en/sockets.examples.php> and node.js? . I have chat with use websocket php but I don't know will better if this chat will move to node.js ?
Websockets are a transport built on TCP sockets. If you'll notice in the link you provided, the author recommends decoding data frames manually. There are projects that will help you with this, as #oberstet recommended (see also https://github.com/nicokaiser/php-websocket). #Kanaka has a great explanation for the difference between websockets and raw TCP sockets here.
Using node.js is certainly a smart, low-overhead way of rolling out a server for websocket connections. Another option is to use a realtime network. PubNub in particular has a blog post on how to write a chat app in 10 lines of code which is pretty accessible. Briefly, the code is:
Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
Chat Output
<div id=box></div>
<script src=http://cdn.pubnub.com/pubnub.min.js></script>
<script>(function(){
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chat';
PUBNUB.subscribe({
channel : channel,
callback : function(text) { box.innerHTML = (''+text).replace( /[<>]/g, '' ) + '<br>' + box.innerHTML }
});
PUBNUB.bind( 'keyup', input, function(e) {
(e.keyCode || e.charCode) === 13 && PUBNUB.publish({
channel : channel, message : input.value, x : (input.value='')
})
} )
})()</script>
A simple approach like this will allow you to cut out the server hosting and configuration entirely. Hope this helps!
This is like asking "what's the difference between PHP and HTTP". Node.js is a technology framework you write code in. WebSockets is a protocol which can be implemented using a technology framework. You can use Node.js to implement the server-side aspect of WebSockets.

Categories

Resources