Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-hosted Screen-Sharing #56

Open
Jing-Springshare opened this issue Jun 26, 2013 · 2 comments
Open

Self-hosted Screen-Sharing #56

Jing-Springshare opened this issue Jun 26, 2013 · 2 comments

Comments

@Jing-Springshare
Copy link

I noticed the Pluginfree-Screen-Sharing is using the services at firebaseio.com

Is that possible to self hosted it?

Which node.js file we could use to start the services?

Thanks,

@muaz-khan
Copy link
Owner

All recent WebRTC Experiments and libraries are capable to work with each and every signaling gateway. Signaling process is highly simplified. If you want to use socket.io over node.js, here is your signaler.js code:

io.sockets.on('connection', function (socket) {
    socket.on('message', function (data) {
        socket.broadcast.emit('message', data);
    });
});

And here is the client-side code overriding openSignlaingChannel method:

connection.openSignalingChannel = function(callback) {
    return io.connect().on('message', callback);
};

Try New Screen Sharing Demo. Source Code

Expectations for custom signaling gateways

  1. Data from onmessage is passed over callback object
  2. Socket instance is returned for reusability e.g. return socket;

That socket instance must have a send method. Otherwise; you should declare a custom send method there:

// declaring custom "send" method
socket.send = function(data) {
    xhr.post('/controller/action', data);
};

WebSockets for signlaing

connection.openSignalingChannel = function (callback) {
    var websocket = new WebSocket('ws://domain:protocol/');

    // data from "onmessage" must be passed over "callback" object
    websocket.onmessage = function (e) {
        callback(e.data);
    };

    // socket object must be returned for reusability
    return websocket;
};

WebSync for signaling

connection.openSignalingChannel = function (callback) {
    var username = Math.round(Math.random() * 60535) + 5000;

    var client = new fm.websync.client('websync.ashx');

    client.setAutoDisconnect({
        synchronous: true
    });

    // received message must be passed over "callback" object
    client.connect({
        onSuccess: function () {
            client.join({
                channel: '/namespace',
                userId: username,
                userNickname: username,
                onReceive: function (event) {
                    callback(event.getData().text);
                }
            });
        }
    });

    // must have a "send" method
    return {
        send: function (message) {
            client.publish({
                channel: '/namespace',
                data: {
                    username: username,
                    text: message
                }
            });
        }
    };
};

XHR for signaling

connection.openSignalingChannel = function (callback) {
    var messages = {};

    function repeatedlyCheck() {
        xhr('/GetData', function (data) {
            if (data != false && !messages[data.ID]) {
                messages[data.ID] = data.Message;

                // data must be passed over "callback" object
                callback(data.Message);

                setTimeout(repeatedlyCheck, 1);
            } else setTimeout(repeatedlyCheck, 400);
        });
    }

    repeatedlyCheck();

    // if there is no "send" method
    // must declare one
    // also socket instance must be returned
    return {
        send: function (data) {
            xhr('/PostData', null, data);
        }
    };
};

@ghost
Copy link

ghost commented Nov 14, 2016

Hello, @muaz-khan Is it possible to share desktop screen without using any extension ? Just by capturing the screen stream and displaying it ?? what constraints should i use ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants