Browse Source

add stuff for demo

Ben Brittain 12 years ago
parent
commit
2ba24faab1
2 changed files with 20 additions and 5 deletions
  1. 8 4
      example/index.html
  2. 12 1
      example/server.js

+ 8 - 4
example/index.html

@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+
 <html>
   <head>
     <title>Example webrtc.io</title>
@@ -145,12 +145,17 @@
           subdivideVideos();
         });
 
+        
         var room = window.location.hash.slice(1);
-
+        var rooms = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
+        if (room === '') {
+            room = Math.floor(Math.random()*rooms.length);
+            window.location.hash = room;
+        }
         //When connectiong to nodejitsu
         //rtc.connect("http://multiwebrtc.nodejitsu.com/", room);
 
-        //When using lokalhost
+        //When using localhost
         rtc.connect("http://localhost:8000/", room);
 
         rtc.on('add remote stream', function(stream, socketId) {
@@ -171,7 +176,6 @@
       window.onresize = function(event) {
         subdivideVideos();
       };
-
     </script>
   </body>
 </html>

+ 12 - 1
example/server.js

@@ -2,6 +2,7 @@ var app = require('express').createServer();
 var io = require('webrtc.io').listen(app);
 
 var colors = {};
+var servers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
 
 //When connectiong to nodejitsu
 //app.listen(80);
@@ -17,6 +18,15 @@ app.get('/style.css', function (req, res) {
   res.sendfile(__dirname + '/style.css');
 });
 
+function selectRoom(socket) {
+    for (var room in servers) {
+        console.log('***' + room);
+        if (io.sockets.clients(room).length < 4){
+            socket.emit('send', room);
+        }
+        console.log(io.sockets.clients('' + room));
+    }
+}
 io.sockets.on('connection', function(socket) {
   console.log("connection received");
 
@@ -29,4 +39,5 @@ io.sockets.on('connection', function(socket) {
       color: colors[socket.id]
     });
   });
-});
+
+});