Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

support dynamic rooms

  • Loading branch information...
commit 96b1dac6e486fa6025b02d744b3ee8c690f5963c 1 parent bd3b309
Markos Calderon authored April 30, 2012

Showing 2 changed files with 15 additions and 4 deletions. Show diff stats Hide diff stats

  1. 4  README
  2. 15  app.js
4  README
... ...
@@ -1 +1,5 @@
1 1
 BigBlueButton Node.js Client
  2
+
  3
+For run the project:
  4
+
  5
+node app.js
15  app.js
@@ -34,10 +34,6 @@ participants_module.hello();
34 34
 
35 35
 //Rooms
36 36
 var rooms = {};
37  
-rooms['Demo Meeting'] = {};
38  
-rooms['English 232'] = {};
39  
-rooms['English 411'] = {};
40  
-
41 37
 // Routes
42 38
 
43 39
 app.get('/', routes.index);
@@ -59,6 +55,11 @@ io.sockets.on('connection', function (socket) {
59 55
 		socket.username = username;
60 56
 		socket.room = meetingID;
61 57
 		
  58
+		// if room doesn't exist create it...
  59
+		if(rooms[meetingID] == undefined){
  60
+			rooms[meetingID] = {}
  61
+		}
  62
+		
62 63
 		// add the client's username to the room
63 64
 		rooms[meetingID][username] = username;
64 65
 		
@@ -79,6 +80,12 @@ io.sockets.on('connection', function (socket) {
79 80
 	socket.on('disconnect', function(){
80 81
 		// remove the username from global usernames list
81 82
 		delete rooms[socket.room][socket.username];
  83
+		
  84
+		//delete room if the room is empty
  85
+		if(Object.keys(rooms[socket.room]).length == 0){
  86
+			delete rooms[socket.room];
  87
+		}
  88
+		
82 89
 		// update list of users in chat, client-side
83 90
 		io.sockets.to(socket.room).emit('updateusers', rooms[socket.room]);
84 91
 		// echo globally that this client has left

0 notes on commit 96b1dac

Please sign in to comment.
Something went wrong with that request. Please try again.