antoine-pous / node-teamspeak3-client

😱 A TeamSpeak3 ServerQuery client with anti-ban feature, prepared statements and a lot of cool stuffs
ISC License
5 stars 0 forks source link

Little question because await #9

Closed XeroxDev closed 6 years ago

XeroxDev commented 6 years ago

Hey, do you maybe know, why this not works?:

private loginHandler(socket: SocketIO.Socket, user: User) {
        socket.on('login', async (data: ILoginData) => {
            [...]
            user.client.on('error', (e) => Server.defaultErrorHandling(e, user));
            Server.ts3Preparing(user.client);

            if (!data.whitelisted)
                user.client.disableAntiFlood();

            await user.client.connect(data.host, data.qport).catch((e) => Server.defaultErrorHandling(e, user));

            let logged = await user.client.execute('login', [data.user, data.password]).catch((e) => {
                if (e.id > 0) {
                    user.sendDanger(e.message);
                    user.emit('activateLogin');
                    return; // Don't continue
                }
            });

            if (!logged) return user.emit('activateLogin');
            [...]
        });
}

the await is not working, also "logged" is undefined. What do I wrong? O.o

Kind regards XeroxDev

XeroxDev commented 6 years ago

I think I found the issue / an issue:

https://xcloud.xeroxdev.de/users/XeroxDev/Screenshots/XeroxCloud-12.12.17-15.35.20.png

SOLVED It was my fault, my Client-Side sended the wrong informations.

antoine-pous commented 6 years ago

Hi!

You can listen socket events to detect the connection close/end.

With these listeners you can reconnect the client and avoid this kind of error.

I'll fix this one to give an error which use the TS3 style.