Fix bugs
Fix bugs
This commit is contained in:
12
hqnode.js
12
hqnode.js
@@ -57,7 +57,7 @@ request('https://api-quiz.hype.space/shows/now', (error, response, body) => {
|
||||
ws.on('open', () => {
|
||||
setInterval(() => ping(ws), 10000);
|
||||
console.log('Master connected to websocket');
|
||||
playersInGame.forEach((player, index) => {
|
||||
playersInGame.forEach((player) => {
|
||||
const playerOptions = {
|
||||
headers: {
|
||||
Authorization: `Bearer ${player.accessToken}`,
|
||||
@@ -65,9 +65,9 @@ request('https://api-quiz.hype.space/shows/now', (error, response, body) => {
|
||||
};
|
||||
const pws = new WebSocket(socketUrl, playerOptions);
|
||||
pws.on('open', () => {
|
||||
console.log(`Player #${index} has connected to websocket`);
|
||||
console.log(`Player ${player.username} has connected to websocket`);
|
||||
pws.send(JSON.stringify({ type:'subscribe', broadcastId }), () => {
|
||||
console.log(`\tPlayer #${index} has subscribed to game`);
|
||||
console.log(`\tPlayer ${player.username} has subscribed to game`);
|
||||
player.activate(broadcastId, pws);
|
||||
});
|
||||
});
|
||||
@@ -111,7 +111,7 @@ request('https://api-quiz.hype.space/shows/now', (error, response, body) => {
|
||||
switch (input.length) {
|
||||
case 1:
|
||||
playersInGame.forEach((player, index) => {
|
||||
console.log(`Player #${index} sent answer ${input[0]}`);
|
||||
console.log(`Player ${player.username} sent answer ${input[0]}`);
|
||||
const callback = (correct) => {
|
||||
if (!correct) playersInGame.splice(index, 1);
|
||||
};
|
||||
@@ -120,7 +120,7 @@ request('https://api-quiz.hype.space/shows/now', (error, response, body) => {
|
||||
break;
|
||||
case 2:
|
||||
playersInGame.forEach((player, index) => {
|
||||
console.log(`Player #${index} sent answer ${input[index % 2]}`);
|
||||
console.log(`Player ${player.username} sent answer ${input[index % 2]}`);
|
||||
const callback = (correct) => {
|
||||
if (!correct) playersInGame.splice(index, 1);
|
||||
};
|
||||
@@ -129,7 +129,7 @@ request('https://api-quiz.hype.space/shows/now', (error, response, body) => {
|
||||
break;
|
||||
case 3:
|
||||
playersInGame.forEach((player, index) => {
|
||||
console.log(`Player #${index} sent answer ${input[index % 3]}`);
|
||||
console.log(`Player ${player.username} sent answer ${input[index % 3]}`);
|
||||
const callback = (correct) => {
|
||||
if (!correct) playersInGame.splice(index, 1);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user