I've build mine own rtc chat, based on simplewertc and nodejs. I have a function, that check if users online or not
var users = {};
io.on('connection', function(socket){
console.log('a user connected');
socket.on('login', function(data){
console.log('a user ' + data.userName+ ' connected');
users[socket.id] = data.userName;
});
socket.on('disconnect', function(){
console.log('user ' + users[socket.id] + ' disconnected');
});
});
and on client side on each site page
var name = document.getElementById('name').innerText;
var socket = io.connect();
socket.emit('login',{userName: name});
Var name get from html (which get from user session function), I feel, that its not a good desicion. Should i use socket authrization for this? SHould i use dome new functions in user model? Or not? Webrtc chat working on different simplewebrtc code.
via Node_newbie
No comments:
Post a Comment