These are chat archives for andyet/SimpleWebRTC

26th
Apr 2017
Seyedamirhossein Hesamian
@amir734jj
Apr 26 2017 02:06
var webrtc = new SimpleWebRTC({});

webrtc.on("connectionReady", function() {
    webrtc.joinRoom("chat-amir734jj");
});

webrtc.on("chat-amir734jj", function(sender, channel, data) {
    $("#chat").html($("#chat").html() + "<br>" + sender + channel + data);
});

$("#send").click(function() {
    webrtc.sendToAll("chat-amir734jj", "message", {
        text: $("#message").val()
    });
    $("#message").val("");
});
I wrote this simple code but it simply does not work. webrtc.on("chat-amir734jj" never gets called
Any help would be appreciated.
notasgoodasyou
@notasgoodasyou
Apr 26 2017 06:57

@StudioInteractive I can't seem to get it to work, is there no way to do it with SimpleWebRTC library? Like:

webrtc.on('videoAdded', function (video, peer) {
    console.log('videoAdded', peer.nick);
});

It's pretty straight forward here but this 'videoAdded' event doesn't seem to push to other peers unless they reload the page.

StudioInteractive
@StudioInteractive
Apr 26 2017 08:57
@notasgoodasyou you could try to reconnect to the room after the video added. But you have to Renegotiation somehow with other peers. That they know that your peer have a new video or audio stream.
StudioInteractive
@StudioInteractive
Apr 26 2017 09:05
@amir734jj all messages that are send over sendDirectly or sendToAll are recieved from this method : on('channelMessage', function (peer, label, data)
Saeid Saati
@satsaeid
Apr 26 2017 12:38
@amir734jj hi, first of all it's better to prepare your constructor ! then the problem in your code is there is no event with name "chat-amir734jj" ! if you see list of supported eventes here : https://github.com/andyet/SimpleWebRTC
so you can use 'videoAdded' event and then as @StudioInteractive said use methods like sendDirectly or sendToAll