title: Last joined room member is not getting broadcasted message using socket.io in express app
body: <p><strong>socket.js</strong>
  Step-1 we create socket.js file for all socket events</p>
  <pre><code>var socket_io = require('socket.io'); 
  var io = socket_io()
  var socketApi = {}
  const { instrument } = require(&quot;@socket.io/admin-ui&quot;);
  socketApi.io = io
  socketApi.instrument = instrument;
  io.on('connection', (socket)=&gt;{
  socketApi.socket = socket
   socket.on('joinRoom', (param) =&gt; {
    roomName = 'testRoom';
    socket.join(roomName);
   });
  });
  module.exports = socketApi
  </code></pre>
  <p><strong>bin/www</strong>
  Step-2 socket.js file include in /bin/www file</p>
  <pre><code>var socketApi = require('../socket');
  var io = socketApi.io;
  io.attach(server,{
  cors : { 
   origin : [&quot;*&quot;,&quot;https://admin.socket.io/&quot;],
    credentials: true 
   },
  });
                  
  socketApi.instrument(io, {
   auth: false
  });
  </code></pre>
  <p><strong>user.js</strong>
  Step-3 emitting on saving route of user.js file</p>
  <pre><code>var express = require('express');
  const io = require('../../../../socket.js');
  var router = express.Router();
  router.post('/save',async (req,res)=&gt;{
   io.socket.in('testRoom').emit('demo', 'Broadcast on entry');
  });
  </code></pre>