Skip to content

Commit

Permalink
support dynamic rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
markoscalderon committed Apr 30, 2012
1 parent bd3b309 commit 96b1dac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README
@@ -1 +1,5 @@
BigBlueButton Node.js Client

For run the project:

node app.js
15 changes: 11 additions & 4 deletions app.js
Expand Up @@ -34,10 +34,6 @@ participants_module.hello();

//Rooms
var rooms = {};
rooms['Demo Meeting'] = {};
rooms['English 232'] = {};
rooms['English 411'] = {};

// Routes

app.get('/', routes.index);
Expand All @@ -59,6 +55,11 @@ io.sockets.on('connection', function (socket) {
socket.username = username;
socket.room = meetingID;

// if room doesn't exist create it...
if(rooms[meetingID] == undefined){
rooms[meetingID] = {}
}

// add the client's username to the room
rooms[meetingID][username] = username;

Expand All @@ -79,6 +80,12 @@ io.sockets.on('connection', function (socket) {
socket.on('disconnect', function(){
// remove the username from global usernames list
delete rooms[socket.room][socket.username];

//delete room if the room is empty
if(Object.keys(rooms[socket.room]).length == 0){
delete rooms[socket.room];
}

// update list of users in chat, client-side
io.sockets.to(socket.room).emit('updateusers', rooms[socket.room]);
// echo globally that this client has left
Expand Down

0 comments on commit 96b1dac

Please sign in to comment.