These are chat archives for andyet/SimpleWebRTC

Apr 2015
Apr 30 2015 16:16

@fippo @xdumaine
i want to use simplewebrtc to connect 3 remote offices in a local area network. so there are always the same three 3 peers connecting on the html page "web-rtc.html". i'm providing different content for the different offices on the page using a get parameter for each office in the url like "web-rtc.html?office=a", "web-rtc.html?office=b" and "web-rtc.html?office=c".

i'm looking for a solution to identfy the different peers on connection to add the correct office description to the videos. i was thinking of using the "sendDirectlyToAll()" function to transfer the value of the office get parameter on connection but i do not know how to use this function correctly.
would somebody be so kind to give me an example of how to send a variable with "sendDirectlyToAll()" to all peers and how to receive it?

i've tried to send using
'''webrtc.sendDirectlyToAll('myRoom', 'myLabel', myVar);
and receive using
webrtc.on('channelMessage', function (peer, label, data) {
but it did not work.

or is there another, perhaps easier way of getting the peers url?
thanks for your help in advance!

Xander Dumaine
Apr 30 2015 19:36
@shlanga I believe using sendDirectlyToAll like in your example is the best way to do this, and is how I've achieved a similar feature in an app. I think the key here is "but it did not work" - you'll need to narrow down what exactly is not working. If you pass debug: true as one of the options to the SimpleWebRTC constructor, you can get additional logging in the console. That might help you identify what events are being fired, or if there are any problems.
One thing to remember is that calling sendDirectlyToAll won't work until the connections are active and the datachannel is ready. Have you waited until connections are fully established to make that call, or are you trying to send the message immediately?
@SometimesSean you'll either have to serve the app from the same domain as your signaling server, or have the signaling server return a CORS header to whitelist the domain from which the app is run. Another option to use only for development (DO NOT USE THIS ALL THE TIME) is to disable CORS checking. I'm not sure there's a way to do this without an extension in firefox, but with chrome, you can launch with the --disable-web-security flag.