简体   繁体   中英

Socket.IO ping without client-side script

I have an Android application and when somebody forces it to stop it doesn't fire the disconnect event on the server side.

Since I can't force people to update their android app, I can't make a ping event handler on the client side. How could I check on the server side whether the client is active without client-side modification?

You need to find out why the disconnect event doesn't fire.
Have you put the socket's disconnect event inside the connection callback?
Also pay attention to variable io and socket . Maybe you put it wrong.

io.on('connection', function (socket) {
  console.log('user connected');

  socket.on('disconnect', function () {
    console.log('user disconnected');
  });
});

If the structure is already right, then I believe you should check the client's code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM