diff --git a/index.js b/index.js new file mode 100644 index 0000000..32a10d7 --- /dev/null +++ b/index.js @@ -0,0 +1,19 @@ +var express = require('express'); +var socket = require('socket.io'); + +// App setup +var app = express(); +var server = app.listen(4000, function(){ + console.log('listening for requests on port 4000,'); +}); + +// Static files +app.use(express.static('public')); + +// Socket setup & pass server +var io = socket(server); +io.on('connection', (socket) => { + + console.log('made socket connection', socket.id); + +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..7a08894 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "websockets-playlist", + "version": "1.0.0", + "description": "A chat app using WebSockets", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/iamshaunjp/websockets-playlist.git" + }, + "author": "The Net Ninja", + "license": "ISC", + "bugs": { + "url": "https://github.com/iamshaunjp/websockets-playlist/issues" + }, + "homepage": "https://github.com/iamshaunjp/websockets-playlist#readme", + "dependencies": { + "express": "^4.15.2", + "socket.io": "^1.7.3" + }, + "devDependencies": { + "nodemon": "^1.11.0" + } +} diff --git a/public/chat.js b/public/chat.js new file mode 100644 index 0000000..84b5877 --- /dev/null +++ b/public/chat.js @@ -0,0 +1,2 @@ +// Make connection +var socket = io.connect('http://localhost:4000'); diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..5aeaeff --- /dev/null +++ b/public/index.html @@ -0,0 +1,14 @@ + + +
+ +