|  | @@ -0,0 +1,28 @@
 | 
	
		
			
				|  |  | +var app = require('express').createServer();
 | 
	
		
			
				|  |  | +var io = require('webrtc.io').listen(app);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +var colors = {};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +app.listen(8000);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +app.get('/', function (req, res) {
 | 
	
		
			
				|  |  | +  res.sendfile(__dirname + '/index.html');
 | 
	
		
			
				|  |  | +});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +app.get('/style.css', function (req, res) {
 | 
	
		
			
				|  |  | +  res.sendfile(__dirname + '/style.css');
 | 
	
		
			
				|  |  | +});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +io.sockets.on('connection', function(socket) {
 | 
	
		
			
				|  |  | +  console.log("connection received");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  colors[socket.id] = Math.floor(Math.random()* 0xFFFFFF)
 | 
	
		
			
				|  |  | +  socket.on('chat msg', function(msg) {
 | 
	
		
			
				|  |  | +    console.log("chat received");
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    socket.broadcast.emit('receive chat msg', {
 | 
	
		
			
				|  |  | +      msg: msg,
 | 
	
		
			
				|  |  | +      color: colors[socket.id]
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  | +});
 |