Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
server DisconnectUser if user open another program in andorid

I have a script chat and it works fine, but if the member enters through Android and leaves the chat and opens any other program, the server will remove it this is my server js commond

//DisconnectUser
    io.use((socket, next) => { next(); }).on('connection', socket => { console.log('(default) client connected'); });
    socket.on("disconnect", function () {
        var userData = UserInfo[socket.id];
        if (typeof userData !== "undefined") {
            if (UserInfo[socket.id].powers["stealth"] == 1000 && UserInfo[socket.id].stealth == true) {
            } else {
                io.to(userData.idroom).emit("msg", {
                    cmd: "msg",
                    data: {
                        bg: "none",
                        class: "hmsg",
                        topic: userData.username,
                        msg: "( هذا المستخدم غادر الدردشة)",
                        roomid: userData.idroom,
                        pic: userData.pic,
                    },
                });
            }
            if (UserInfo[socket.id].uid) {
                var UpdateUser = {
                    $set: {
                        lastssen: new Date().getTime(),
                        token: stringGen(177),
                    },
                };

                user_list.updateOne({ id: UserInfo[socket.id].uid }, UpdateUser, function (err, uruser) {
                    if (err) throw err;
                    if (uruser) {
                    }
                });
            }
            io.emit("msg", { cmd: "ur", data: [userData.id, null] });
            socket.leave(userData.idroom);
        }
        delete UserInfo[socket.id];

        const indexw = online.findIndex((x) => x.id == socket.id);
        if (indexw != -1) {
            online.splice(
                online.findIndex((v) => v.id == socket.id),
                1
            );
            io.emit("msg", { cmd: "u-", data: socket.id });
        }

        var index = UserEntre.findIndex((x) => x == socket.id);
        if (index != -1) {
            UserEntre.splice(UserEntre.indexOf(socket.id), 1);
        }

        lastssen: new Date().getTime();
    });

**What do I do to keep the user in the chat for the longest time? **

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda