diff --git a/README.md b/README.md index c18a098c0..c81d92743 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # chat-example -This is the source code for a very simple chat example used for +This is an updated version of source code for a very simple chat example used for the [Getting Started](http://socket.io/get-started/chat/) guide of the Socket.IO website. -Please refer to it to learn how to run this application. +This version does not use Jquery it's plain JavaScript and the Index.js is a bit more modern diff --git a/index.html b/index.html index 5f2767e98..d22927842 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,8 @@ - - Socket.IO chat + + + Node Realtime Experiment - - + +
- - + diff --git a/index.js b/index.js index a322dca0f..0e0e5bada 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,27 @@ -var app = require('express')(); +var express = require('express'); +var app = express(); var http = require('http').Server(app); var io = require('socket.io')(http); -app.get('/', function(req, res){ - res.sendFile(__dirname + '/index.html'); +app.set('port', (process.env.PORT || 3000)); + +app.use("/", express.static(__dirname + '/public')); + +app.get('/', function (req,res) { + res.sendFile(__dirname + '/public/index.html'); }); io.on('connection', function(socket){ - socket.on('chat message', function(msg){ - io.emit('chat message', msg); - }); + console.log("Someone Connected"); + socket.on('chat message', function(msg){ + io.emit('chat message', msg); + }); +}); + +io.on('disconnect', function(msg) { + console.log("Someone Disconnected"); }); -http.listen(3000, function(){ - console.log('listening on *:3000'); +http.listen(app.get('port'), function(){ + console.log('Server Started : listening on *:3000'); }); diff --git a/package.json b/package.json index 46f75814b..7e1b3ddae 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "socket-chat-example", + "name": "socket-chat-example-updated", "version": "0.0.1", - "description": "my first socket.io app", + "description": "cool realtime chat socket.io app", "dependencies": { - "express": "4.10.2", - "socket.io": "1.2.0" + "express": "^4.12.4", + "socket.io": "^1.3.5" } }