diff --git a/app/assets/javascripts/src/Metamaps.js.erb b/app/assets/javascripts/src/Metamaps.js.erb index 19079adb..c9334289 100644 --- a/app/assets/javascripts/src/Metamaps.js.erb +++ b/app/assets/javascripts/src/Metamaps.js.erb @@ -1972,10 +1972,7 @@ Metamaps.Realtime = { if (self.localVideo && self.status) { $('#wrapper').append(self.localVideo.view.$container); } - self.socket.emit('videoAdded', { - avatar: Metamaps.Active.Mapper.get('image'), - username: Metamaps.Active.Mapper.get('name') - }); + self.socket.emit('videoAdded'); self.webrtc.webrtc.peers.forEach(function (p) { p.pc.addStream(self.webrtc.webrtc.localStream); p.start(); @@ -2060,13 +2057,6 @@ Metamaps.Realtime = { self.room.join(function (err, roomDesc) { //attachMediaStream(self.webrtc.webrtc.localStream, self.localVideo.$video[0]); - for (id in roomDesc.avatars) { - self.webrtc.webrtc.peers.find(function(p) { return p.id === id; }).avatar = roomDesc.avatars[id]; - } - for (id in roomDesc.usernames) { - self.webrtc.webrtc.peers.find(function(p) { return p.id === id; }).username = roomDesc.usernames[id]; - } - function addVideo(v) { // random position for now var top = Math.floor((Math.random() * ($('#wrapper').height() - 100)) + 1); diff --git a/realtime/signal.js b/realtime/signal.js index 5c27a653..5d9a63f7 100644 --- a/realtime/signal.js +++ b/realtime/signal.js @@ -3,20 +3,15 @@ var uuid = require('node-uuid'); module.exports = function(io, stunservers) { var - activePeople = 0, - activeRooms = {}; + activePeople = 0; function describeRoom(name) { var clients = io.sockets.clients(name); var result = { - clients: {}, - avatars: {}, - usernames: {} + clients: {} }; clients.forEach(function (client) { result.clients[client.id] = client.resources; - result.avatars[client.id] = client.avatar; - result.usernames[client.id] = client.username; }); return result; } @@ -32,14 +27,6 @@ module.exports = function(io, stunservers) { io.sockets.on('connection', function (client) { activePeople += 1; - client.on('setDetails', function (details) { - client.profile = { - username: details.username, - image: details.image - }; - client.broadcast.emit('presence', client.profile); - }); - client.resources = { screen: false, video: false, @@ -72,27 +59,13 @@ module.exports = function(io, stunservers) { function videoAdded(data) { var socketsInRoom = io.sockets.clients(client.room); client.resources.video = true; - client.avatar = data.avatar; - client.username = data.username; socketsInRoom.forEach(function(socket) { if (socket.id !== client.id) { - socket.emit('addVideo', { id: client.id, avatar: data.avatar, username: data.username }); + socket.emit('addVideo', { id: client.id }); } }); } - client.on('requestRoomCount', function(name) { - client.emit('room_count', { - room_id: name, - count: io.sockets.clients(name).length - }); - }); - - client.on('requestActiveRooms', function() { - client.emit('rooms_count', Object.keys(activeRooms).length); - }); - - function removeFeed(type) { if (client.room) { io.sockets.in(client.room).emit('remove', { @@ -101,22 +74,6 @@ module.exports = function(io, stunservers) { }); if (!type) { client.leave(client.room); - } - io.sockets.emit('room_count', { - room_id: client.room, - count: io.sockets.clients(client.room).length - }); - if (client.profile) { - client.broadcast.emit('vacated_room', { - room_id: client.room, - profile: client.profile - }); - } - if (io.sockets.clients(client.room).length == 0) { - delete activeRooms[client.room]; - io.sockets.emit('rooms_count', Object.keys(activeRooms).length); - } - if (!type) { client.room = undefined; } } @@ -129,27 +86,7 @@ module.exports = function(io, stunservers) { removeFeed(); safeCb(cb)(null, describeRoom(name)); client.join(name); - io.sockets.emit('room_count', { - room_id: name, - count: io.sockets.clients(name).length - }); - if (client.profile) { - client.broadcast.emit('presence_room', { - room_id: name, - profile: client.profile - }); - } - io.sockets.clients(name).forEach(function (s) { - if (s.profile) { - client.emit('presence_room', { - room_id: name, - profile: s.profile - }); - } - }); client.room = name; - activeRooms[name] = true; - io.sockets.emit('rooms_count', Object.keys(activeRooms).length); } // we don't want to pass "leave" directly because the @@ -157,10 +94,6 @@ module.exports = function(io, stunservers) { client.on('disconnect', function () { removeFeed(); activePeople -= 1; - io.sockets.emit('users_count', activePeople); - if (client.profile) { - io.sockets.emit('vacated', client.profile); - } }); client.on('leave', function () { removeFeed(); @@ -185,11 +118,5 @@ module.exports = function(io, stunservers) { // tell client about stun and turn servers and generate nonces client.emit('stunservers', stunservers || []); - - client.emit('rooms_count', Object.keys(activeRooms).length); - io.sockets.emit('users_count', activePeople); - io.sockets.clients().forEach(function (socket) { - if (socket.id !== client.id && socket.profile) client.emit('presence', socket.profile); - }); }); };