Forked from laterbreh/Express 4 and Socket.io: Passing socket.io to routes - app.js
Created
March 16, 2018 22:35
-
-
Save m0sk1t/de13f35bad5319c1bd145a977b4e7ec5 to your computer and use it in GitHub Desktop.
Revisions
-
laterbreh renamed this gist
Jan 4, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
laterbreh revised this gist
Dec 25, 2015 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +0,0 @@ -
laterbreh revised this gist
Dec 25, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ //////////////////////////////////////////// Other sources of information on this topic: //////////////////////////////////////////// http://stackoverflow.com/questions/31016350/using-socket-io-with-express-4-generator -
laterbreh revised this gist
Dec 25, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ var app = express(); app.io = require('socket.io')(); var routes = require('./routes/index')(app.io); app.use('/', routes); -
laterbreh revised this gist
Dec 25, 2015 . No changes.There are no files selected for viewing
-
laterbreh created this gist
Dec 25, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ var app = express(); app.io = require('socket.io')(); var routes = require('./routes/index')(app.io, passport); app.use('/', routes); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ //Normal code here //then at the bottom: module.exports = function (io) { //Socket.IO io.on('connection', function (socket) { console.log('User has connected to Index'); //ON Events socket.on('admin', function () { console.log('Successful Socket Test'); }); //End ON Events }); return router; }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ /** * Create HTTP server */ var server = http.createServer(app); app.io.attach(server); /** * Listen on provided port, on all network interfaces. */ server.listen(port); server.on('error', onError); server.on('listening', onListening); /** * Normalize a port into a number, string, or false. */