diff --git a/build/index.html b/build/index.html
index 5b4ebb6..c3a0bb2 100644
--- a/build/index.html
+++ b/build/index.html
@@ -15,6 +15,10 @@
$('#m').val('');
return false;
});
+
+ socket.on('chat message', function(msg){
+ $('#messages').append($('
').text(msg));
+ });
// socket.on('connect', function(data) {
// socket.emit('join', 'Hello World from client');
// console.log("connected")
diff --git a/build/index_chat.html b/build/index_chat.html
new file mode 100644
index 0000000..f865b30
--- /dev/null
+++ b/build/index_chat.html
@@ -0,0 +1,35 @@
+
+
+
+ Socket.IO chat
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/server/app_chat.js b/server/app_chat.js
new file mode 100644
index 0000000..2b84033
--- /dev/null
+++ b/server/app_chat.js
@@ -0,0 +1,37 @@
+var express = require('express');
+var path = require('path');
+var morgan = require('morgan');
+
+
+
+var app = express();
+app.use(morgan('dev'));
+//app.use(express.static(path.resolve(__dirname, '../build')))
+//app.use('/', express.static(path.resolve(__dirname, '../build/index_chat.html')));
+app.use('/', function(req, res){
+ res.sendFile(path.resolve(__dirname, '../build/index_chat.html'))
+});
+
+
+var http = require('http').Server(app);
+//var io = require('socket.io')(http);
+var port = process.env.PORT || 3000;
+
+
+var server = app.listen(port, function(){
+ console.log(`server is now listening on port ${port}`);
+});
+
+var io = require('socket.io').listen(server);
+io.on('connection', function(socket){
+ console.log('a user connected');
+ socket.on('disconnect', function(){
+ console.log('user disconnected')
+ })
+ socket.on('chat message',function(msg){
+ console.log('message: '+msg);
+ io.emit('chat message', msg);
+ });
+});
+
+