So I've been looking around on google for some time. Trying to find an answer online about my question, couldn't find one. So I came here to ask.
Whenever I have my server send an emit event to the client to pick up polling-xhr.js gives me an error saying that the service is unavailable. With a redirect to line 199. Error
Client:
function LoginRequest() {
console.log("Attempting to Send Server Request");
socket.emit("LoginRequest", { socket: socket.id, username: document.getElementById("Username").innerHTML, password: document.getElementById("Password").innerHTML });
}
socket.on("LoginCallback", (info) => {
if(socket.id === info.Socket) {
console.log("Recieved Server Callback.");
if(!info.Error) {
localStorage.setItem("Username", document.getElementById("Username").innerHTML);
localStorage.setItem("Password", document.getElementById("Password").innerHTML);
} else {
return console.log("Username or Password Incorrect");
}}
});
Server:
io.on('connection', (socket) => {
socket.on('LoginRequest', (info) => {
const UserExists = db.fetch(`Usernames`).includes(info.username);
const PasswordCheck = (db.fetch(`Password_${info.username}`) != info.password) ? false : true
const err = (UserExists == true && PasswordCheck == true) ? false : true
io.of("login").emit("LoginCallback", { Exists: UserExists, PasswordCorrect: PasswordCheck, Error: err, Socket: info.socket });
});