Created
February 14, 2016 07:48
-
-
Save outsideris/5d3c0f93ab17a984bcef to your computer and use it in GitHub Desktop.
socket.io room example
This file contains 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 characters
diff --git a/server.js b/server.js | |
index 715596a..4a90df0 100644 | |
--- a/server.js | |
+++ b/server.js | |
@@ -1,7 +1,6 @@ | |
var http = require('http') | |
, fs = require('fs') | |
- , path = require('path') | |
- , io = require('socket.io'); | |
+ , path = require('path'); | |
var server = http.createServer(function(req, res) { | |
var filename = path.join(process.cwd(), req.url); | |
@@ -27,21 +26,9 @@ var server = http.createServer(function(req, res) { | |
}); | |
}); | |
-server.listen(3000); | |
- | |
-io = io.listen(server); | |
- | |
-io.configure(function(){ | |
- io.enable('browser client etag'); | |
- io.set('log level', 3); | |
- io.set('transports', [ | |
- 'websocket' | |
- , 'flashsocket' | |
- , 'htmlfile' | |
- , 'xhr-polling' | |
- , 'jsonp-polling' | |
- ]); | |
- | |
+var io = require('socket.io')(server, { | |
+ transports: ['polling', 'websocket'], | |
+ allowUpgrades: true | |
}); | |
io.sockets.on('connection', function(socket) { | |
@@ -103,4 +90,6 @@ var another = io.of('/another').on('connection', function(socket) { | |
}, 2000); | |
}); | |
+server.listen(3000); | |
+ | |
console.log("서버가 시작되었습니다. http://localhost:3000"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment