node.js - Can't configure Socketio: TypeError: Object #<Server> has no method 'configure' -


i'm trying simple token authorization socketio outlined in docs. node throws:

typeerror: object #<server> has no method 'configure' 

when try configure socketio io.configure. idea why configuration method wouldn't available?

var express = require('express')   , app = express()   , server = require('http').server(app)   , io = require('socket.io')(server)  io.configure(function (){   io.set('authorization', function (handshakedata, callback) {     ... }) 

full stacktrace:

/users/administrator/dev/chat-example/lib/io.js:9   io.configure(function (){      ^ typeerror: object #<server> has no method 'configure'     @ module.exports (/users/administrator/dev/chat-example/lib/io.js:9:6)     @ object.<anonymous> (/users/administrator/dev/chat-example/app.js:4:29)     @ module._compile (module.js:456:26)     @ object.module._extensions..js (module.js:474:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:312:12)     @ function.module.runmain (module.js:497:10)     @ startup (node.js:119:16)     @ node.js:906:3 

io.configure , io.set being deprecated. here sample middleware socket.io 1.x

io.use(function(socket, next) {     var handshake = socket.request;      if (!handshake) {         return next(new error('[[error:not-authorized]]'));     }      cookieparser(handshake, {}, function(err) {         if (err) {             return next(err);         }          var sessionid = handshake.signedcookies['express.sid'];          db.sessionstore.get(sessionid, function(err, sessiondata) {             if (err) {                 return next(err);             }             console.log(sessiondata);              next();         });     }); }); 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -