aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..e92075b
--- /dev/null
+++ b/index.js
@@ -0,0 +1,21 @@
+var app = require('express')();
+var http = require('http').Server(app);
+var io = require('socket.io')(http);
+
+app.get('/', function(req, res){
+ res.sendFile('client/index.html');
+});
+
+io.on('connection', function(socket){
+ console.log('user connected');
+ socket.on('chat message', function(msg){
+ io.emit('chat message', msg);
+ });
+ socket.on('disconnect', function(){
+ console.log('user disconnected');
+ });
+});
+
+http.listen(3000, function(){
+ console.log('listening on *:3000');
+}); \ No newline at end of file