vendredi 31 juillet 2015

Converting a piece of code written for Socket.IO to SignalR

I am trying to implement a video conferencing with SignalR.

I found this sample promising: http://ift.tt/1KqzQ17

The issue I am facing is to implement it with SignalR.

There are two samples given in the same link there.

One with Firebase and other one Sockets:

Want to use Firebase for signaling?

var config = {
    openSocket: function (config) {
        var channel = config.channel || location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
        var socket = new Firebase('http://ift.tt/1guTL4i' + channel);
        socket.channel = channel;
        socket.on('child_added', function (data) {
            config.onmessage(data.val());
        });
        socket.send = function (data) {
            this.push(data);
        }
        config.onopen && setTimeout(config.onopen, 1);
        socket.onDisconnect().remove();
        return socket;
    }
}
Want to use PubNub for signaling?

var config = {
    openSocket: function (config) {
        var channel = config.channel || location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
        var socket = io.connect('http://ift.tt/1OTEMMl' + channel, {
            publish_key: 'demo',
            subscribe_key: 'demo',
            channel: config.channel || channel,
            ssl: true
        });
        if (config.onopen) socket.on('connect', config.onopen);
        socket.on('message', config.onmessage);
        return socket;
    }
}

Can you help me writing that piece of code using SignalR?

Aucun commentaire:

Enregistrer un commentaire