-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (29 loc) · 853 Bytes
/
server.js
File metadata and controls
38 lines (29 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var http = require('http'),
sys = require('sys');
var express = require('express');
var app = express.createServer();
app.configure(function(){
app.use('view engine','jade');
app.use(express.static(__dirname + '/client'));
app.use(express.bodyParser());
});
app.get('/',function(req,res){
res.render('index.jade',{title:'Chat Room'});
});
app.get('/room',function(req,res){
res.render('room.jade',{title:'Chat Room'});
});
var io = require('socket.io').listen(app);
io.set('log level', 1);
io.sockets.on('connection',function(socket){
console.log('Connected');
socket.on('join', function(name){
socket.join(name.room);
var info = JSON.stringify(name);
socket.set('nickname', info, function () { socket.emit('ready'); });
});
socket.on('msg', function(msg){
console.log(JSON.stringify(msg))
});
});
app.listen(8005);