Open gaecom opened 10 years ago
this demo could run successfully between two computer browser. But when i open two browsers in computer A and visit this link ,then i visit this link in another computer B browser ,the computer B browser cant view the shared screen.
@gaecom Can you share console-logs for the browser unable to view the shared screen?
On second system; you're able to see View His Screen
button?
i use socket.io over node.
the problem is: i could view the screen in the second system,on the third system i can see view screen button,but i cant see the screen after i clicked button.
i change the javascript in index.html to the following:
var server = location.protocol+"//"+location.host+"/";
var onMessageCallbacks = {};
var currentUserUUID = Math.round(Math.random() * 60535) + 5000;
var channel = decodeURI(location.hash).split("@@")[0].slice("1");
io.connect(server,{secure: true}).emit('new-channel', {
channel: channel,
sender: currentUserUUID
});
var config = {
openSocket:function (config) {
console.log("channel",channel);
var socketio = io.connect(server+channel);
socketio.on('message', function(data) {
if(data.sender == currentUserUUID) return;
if (onMessageCallbacks[data.channel]) {
onMessageCallbacks[data.channel](data.message);
};
});
onMessageCallbacks[channel] = config.onmessage;
if (config.onopen) setTimeout(config.onopen, 1000);
return {
send: function (message) {
socketio.emit('message', {
sender: currentUserUUID,
channel: channel,
message: message
});
},
channel: channel
};
},
my server code is your node server code copy.
Are you using RTCMultiConnection for screen sharing?
You must be overriding openSignalingChannel
instead of openSocket
.
You can use this single-socket snippet as well:
Above firebase-based demo is also not working for you?
You can try MultiRTC Demo to share screen among multiple users.
If you used addStream
method; then RTCMultiConnection will auto renegotiate streams with new users.
Did you try plugin-free screen sharing experiment as well?
many thanks for your reply.
i've tried RTCMultiConnection one way screen demo with link https://www.webrtc-experiment.com/RTCMultiConnection/OneWay-Screen-TwoWay-Audio.html.
if i defined SIGNALING_SERVER = 'https://webrtc-signaling.nodejitsu.com:443/',the demo works. if i defined SIGNALING_SERVER = 'https://w.cc:443/ which is my node server ,it failed. could your tell me where is webrtc-signaling.nodejitsu.com:443 source code.
the following code is my current node server code.
var fs = require('fs');
var options = {
key: fs.readFileSync('w.cc.key'),
cert: fs.readFileSync('w.cc.cert')
};
var _ = require('lodash-node');
var express = require('express');
var https = require('https');
var app = express(),
server = https.createServer(options,app),
io = require('socket.io').listen(server,{ log: false });
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
//io.configure('production', function(){
// io.enable('browser client etag');
// io.set('log level', 1);
//
//
//});
app.configure(function () {
var hourMs = 1000 * 60 * 60;
app.use(express.static('static', {
maxAge: hourMs
}));
app.use(express.directory('static'));
app.use(express.errorHandler());
});
server.listen(8443);
// ----------------------------------socket.io
var channels = {};
// sometimes it helps!
// io.set('transports', ['xhr-polling']);
io.sockets.on('connection', function (socket) {
console.log("connection");
var initiatorChannel = '';
if (!io.isConnected) {
io.isConnected = true;
}
socket.on('new-channel', function (data) {
if (!channels[data.channel]) {
initiatorChannel = data.channel;
}
channels[data.channel] = data.channel;
onNewNamespace(data.channel, data.sender);
});
socket.on('presence', function (channel) {
var isChannelPresent = !! channels[channel];
socket.emit('presence', isChannelPresent);
});
socket.on('disconnect', function (channel) {
if (initiatorChannel) {
delete channels[initiatorChannel];
}
});
});
function onNewNamespace(channel, sender) {
io.of('/' + channel).on('connection', function (socket) {
if (io.isConnected) {
io.isConnected = false;
socket.emit('connect', true);
}
socket.on('message', function (data) {
if (data.sender == sender)
socket.broadcast.emit('message', data.data);
});
});
}
i change my node server code to the following and it works now.thank you very much.
var channels = {};
// sometimes it helps!
// io.set('transports', ['xhr-polling']);
var fs = require('fs');
var options = {
key: fs.readFileSync('w.cc.key'),
cert: fs.readFileSync('w.cc.cert')
};
var app = require('express')(),
server = require('https').createServer(options, app),
io = require('socket.io').listen(server);
server.listen(8443);
io.sockets.on('connection', function (socket) {
if (!io.connected) io.connected = true;
socket.on('new-channel', function (data) {
onNewNamespace(data.channel, data.sender);
});
});
function onNewNamespace(channel, sender) {
io.of('/' + channel).on('connection', function (socket) {
if (io.isConnected) {
io.isConnected = false;
socket.emit('connect', true);
}
socket.on('message', function (data) {
if (data.sender == sender) socket.broadcast.emit('message', data.data);
});
});
}
https://www.webrtc-experiment.com/RTCMultiConnection/screen-sharing.html