title: How to control when socket connection request is sent to backend from client?
body: <p>Using <code>vue-socket.io</code> my frontend is currently firing off a Socket.io connection request to my backend when my app is being built initially or every time I refresh the page. This is problematic for me as my page gets initially built at the landing page. This means that it is sending a socket request without the proper data since the user hasn't logged in yet. Once the user logs in I am unable to send another socket connection request.</p>
  
  <p><code>socket.js</code> (<code>plugins</code> folder) <strong>FRONTEND</strong></p>
  
  <pre><code>import Vue from "vue";
  import store from "../store";
  import SocketIO from "socket.io-client";
  import VueSocketIO from "vue-socket.io";
  
  Vue.use(
    new VueSocketIO({
      debug: true,
      connection: SocketIO("http://localhost:3000", {
        query: { token: store.state.token }
      }),
      vuex: {
        store,
        actionPrefix: "SOCKET_",
        mutationPrefix: "SOCKET_"
      }
    })
  );
  </code></pre>
  
  <p>socket.js (<code>controllers</code> folder) <strong>BACKEND</strong></p>
  
  <pre><code>io.use(function (socket, next) {
      console.log('Token ' + socket.handshake.query.token);
      if (socket.handshake.query &amp;&amp; socket.handshake.query.token) {
        jwt.verify(socket.handshake.query.token, 'THIS IS SUPPOSED TO BE PRIVATE', function (err, decoded) {
          if (err) return next(new Error('Authentication error'));
          socket.decoded = decoded;
          next();
        });
      } else {
        next(new Error('Authentication error'));
      }
    })
      .on('connection', function (socket) {
        socket.on('JOIN_ROOM', (room) =&gt; {
          socket.join(room);
        });
        // CourseQuestions Page
        socket.on('POST_QUESTION', (data) =&gt; {
  </code></pre>
  
  <p>I am looking for a way to programmatically send off the socket connection request AGAIN from the frontend once the user has logged in preferable using <code>vue-socket.io</code>.</p>