remove extra code

This commit is contained in:
Connor Turland 2015-12-11 18:10:38 -05:00
parent 3c9d722945
commit 5f1ef5f5c8
2 changed files with 4 additions and 87 deletions

View file

@ -1972,10 +1972,7 @@ Metamaps.Realtime = {
if (self.localVideo && self.status) { if (self.localVideo && self.status) {
$('#wrapper').append(self.localVideo.view.$container); $('#wrapper').append(self.localVideo.view.$container);
} }
self.socket.emit('videoAdded', { self.socket.emit('videoAdded');
avatar: Metamaps.Active.Mapper.get('image'),
username: Metamaps.Active.Mapper.get('name')
});
self.webrtc.webrtc.peers.forEach(function (p) { self.webrtc.webrtc.peers.forEach(function (p) {
p.pc.addStream(self.webrtc.webrtc.localStream); p.pc.addStream(self.webrtc.webrtc.localStream);
p.start(); p.start();
@ -2060,13 +2057,6 @@ Metamaps.Realtime = {
self.room.join(function (err, roomDesc) { self.room.join(function (err, roomDesc) {
//attachMediaStream(self.webrtc.webrtc.localStream, self.localVideo.$video[0]); //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) { function addVideo(v) {
// random position for now // random position for now
var top = Math.floor((Math.random() * ($('#wrapper').height() - 100)) + 1); var top = Math.floor((Math.random() * ($('#wrapper').height() - 100)) + 1);

View file

@ -3,20 +3,15 @@ var uuid = require('node-uuid');
module.exports = function(io, stunservers) { module.exports = function(io, stunservers) {
var var
activePeople = 0, activePeople = 0;
activeRooms = {};
function describeRoom(name) { function describeRoom(name) {
var clients = io.sockets.clients(name); var clients = io.sockets.clients(name);
var result = { var result = {
clients: {}, clients: {}
avatars: {},
usernames: {}
}; };
clients.forEach(function (client) { clients.forEach(function (client) {
result.clients[client.id] = client.resources; result.clients[client.id] = client.resources;
result.avatars[client.id] = client.avatar;
result.usernames[client.id] = client.username;
}); });
return result; return result;
} }
@ -32,14 +27,6 @@ module.exports = function(io, stunservers) {
io.sockets.on('connection', function (client) { io.sockets.on('connection', function (client) {
activePeople += 1; activePeople += 1;
client.on('setDetails', function (details) {
client.profile = {
username: details.username,
image: details.image
};
client.broadcast.emit('presence', client.profile);
});
client.resources = { client.resources = {
screen: false, screen: false,
video: false, video: false,
@ -72,27 +59,13 @@ module.exports = function(io, stunservers) {
function videoAdded(data) { function videoAdded(data) {
var socketsInRoom = io.sockets.clients(client.room); var socketsInRoom = io.sockets.clients(client.room);
client.resources.video = true; client.resources.video = true;
client.avatar = data.avatar;
client.username = data.username;
socketsInRoom.forEach(function(socket) { socketsInRoom.forEach(function(socket) {
if (socket.id !== client.id) { 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) { function removeFeed(type) {
if (client.room) { if (client.room) {
io.sockets.in(client.room).emit('remove', { io.sockets.in(client.room).emit('remove', {
@ -101,22 +74,6 @@ module.exports = function(io, stunservers) {
}); });
if (!type) { if (!type) {
client.leave(client.room); 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; client.room = undefined;
} }
} }
@ -129,27 +86,7 @@ module.exports = function(io, stunservers) {
removeFeed(); removeFeed();
safeCb(cb)(null, describeRoom(name)); safeCb(cb)(null, describeRoom(name));
client.join(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; 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 // we don't want to pass "leave" directly because the
@ -157,10 +94,6 @@ module.exports = function(io, stunservers) {
client.on('disconnect', function () { client.on('disconnect', function () {
removeFeed(); removeFeed();
activePeople -= 1; activePeople -= 1;
io.sockets.emit('users_count', activePeople);
if (client.profile) {
io.sockets.emit('vacated', client.profile);
}
}); });
client.on('leave', function () { client.on('leave', function () {
removeFeed(); removeFeed();
@ -185,11 +118,5 @@ module.exports = function(io, stunservers) {
// tell client about stun and turn servers and generate nonces // tell client about stun and turn servers and generate nonces
client.emit('stunservers', stunservers || []); 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);
});
}); });
}; };