Synchronous request in node.js

I am using socket.io and express 4.In my code I want to call io.sockets.on('connection', function (socket){} only after app.get('/getMsg', function (req, res){} so that I can access session.id. I am new to node.js please help.

// app.get request is made by client.

app.get('/getMsg', function (req, res) {
  a = req.session.id;
});

io.sockets.on('connection', function (socket){

    socket.on('chat message', function(msg){
      var user;
      for(var i=id.length-1; i>=0; i--){
        if(id[i].sid == a){
          user=id[i].username;
          break;
        }
      }
      io.emit('chatmessage',user,msg);
    }); 
});