javascript - Send event to client, from server, and then disconnect the socket (from server) -


i want send event client, in socket.io, , after disconnect client. problem calling socket.emit() not emit anything... know, or stepped kind of problem?

my code this: - on server:

usercredentialscheck: function (socket, next, callback) {     applogsys.info('check cookie!');     .....     var handshake = socket.request;     .....     parsecookie(handshake, null, function (err, data) {         sessionsrv.get(handshake, function (err, session) {             if (err) {                 applogsys.error(err.message);                 next(new error(err.message));             }             else             {                 ......                 socket.emit('na', 'error checking session! bye!');                 socket.disconnect();             }           })     }) }; 

on client:

appsocket.on('na', function(d){         console.log('error: '+d);         console.log('now, redirect!');         //redirect!         var delay = 1000; //your delay in milliseconds         var url   = '/';         settimeout(function(){ window.location = url; }, delay);     }); 

thank you!


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -