I am still new with nodejs, still not sure how to access a variable in a function and call the variable back.
check few links: but im getting really confused. Please help!
Node.JS: How to pass variables to asynchronous callbacks?
How can we access variable from callback function in node.js?
var express = require('express');
var app = express();
var router = express.Router();
var https = require('https').createServer( ssl_options, app);
var io = require('socket.io')( https );
**var user_id;
var room_id;**
router.use(function(req, res, next) {
next();
});
app.use('/chat',router);
router.route( '/chat/:user_id/:room_id' )
.get(function(req,res){
res.sendFile( __dirname + '/index.html' );
user_id = req.param('user_id');
room_id = req.param('room_id');
});
https.listen(3000);
io.on('connection', function(socket){
**console.log ( user_id );
console.log ( room_id );**
});
No comments:
Post a Comment