I'm encountering an issue where, after failing to sign in and then successfully signing into my game, it creates a game instance for every failed login attempt. This same problem occurs with failed sign-up attempts as well.
I would like to provide more code for context, but Stack Overflow requires even more details which I am unsure of. Therefore, I'll just link my repository.
Single failed attempt: image
Two game instances created: image
My repository: elevaidusTS
SERVER
socket.on('signIn', (signInInfo: any) => {
let sql = 'SELECT * FROM player WHERE username = ? AND password = ?';
var query = this.db.query(sql, [signInInfo.username,signInInfo.password], (err, res) => {
if (err) {
console.log(err);
socket.emit('errorFromBackend', err.code);
}else if(res.length === 0){
socket.emit('errorFromBackend', 'username and or password was incorrect');
}else{
console.log(`\n\n===============>\t Player logging in\n`)
console.log(`===============>\t username: ${signInInfo.username}\n`)
console.log(`===============>\t password: ${signInInfo.password}\n`)
this.CreatePlayer(socket, { player: res[0], isNew: false });
}
})
})
CLIENT
public SignIn(): void {
this.socket.emit('signIn', {username: signInUsername.value, password: signInPassword.value })
this.socket.on('signedIn', (playerInfo: any) => {
this.CreateGame(playerInfo);
})
this.socket.on('errorFromBackend', (err: string) => {
alert(err);
})
}
public SignUp(): void {
this.socket.emit('signUp', {username: signInUsername.value, password: signInPassword.value })
this.socket.on('signedUp', (playerInfo: any) => {
this.CreateGame(playerInfo)
})
this.socket.on('errorFromBackend', (err: string) => {
alert(err);
})
}