Here is the solution to your problem
Firstly, on your server side you can implement and bind user credentials to token as shown below.
var jwt = require('jsonwebtoken'); app.post('/loginpage',function(req,res){
On the server side of socket.io you can do the following
//require socket.io var xxx = socketIo.listen //to the server xxx.set('auth',socketIojwtauthorize({ secret: config.secrets.session, handshake: true })); xxx.sockets //here connection on or off by setting up promise //server listen to localhost and port of your choice
When client sends a valid jwt connection, it starts
A simple client-side file contains the following modules
//function connectsocket(token){ //connect( //and query the token ); } //socket.on('connect',function(){ //generate the success message here }).on('disconnect',function(){ //your choice }) //rendering the routes with the server side $.post('/loginroute',{ //user credentials passes here }).done(function(bind){ connect_socket( bind.token )})
source share