From 1b2ef53aaadd043f590801c50bb0e562fce35a2f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 10 Feb 2019 11:17:31 -0500 Subject: getting the basics --- index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 index.js (limited to 'index.js') 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 -- cgit v1.2.3