Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Jun 12, 2024
1 parent 0d9c7c8 commit c11089d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ebs/src/modules/game/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export class GameConnection {
console.error("Could not parse message" + msgText);
return;
}
console.log(`Got message ${JSON.stringify(msg)}`);
if (msg.messageType !== MessageType.Ping)
console.log(`Got message ${JSON.stringify(msg)}`);
this.processMessage(msg);
});
ws.on("close", (code, reason) => {
Expand Down Expand Up @@ -102,7 +103,7 @@ export class GameConnection {
if (err)
console.error(err);
});
if (msg.messageType !== MessageType.Ping)
if (msg.messageType !== MessageType.Pong)
console.debug(`Sent message ${JSON.stringify(msg)}`);
}
public makeMessage(type: MessageType, guid?: string): Message {
Expand All @@ -118,6 +119,7 @@ export class GameConnection {
new Promise<ResultMessage>((resolve, reject) => {
if (!transactionId) {
reject(`Tried to redeem without transaction ID`);
return;
}

const msg: RedeemMessage = {
Expand All @@ -132,11 +134,13 @@ export class GameConnection {
} as RedeemMessage;
if (this.outstandingRedeems.has(msg.guid)) {
reject(`Redeeming ${msg.guid} more than once`);
return;
}
this.outstandingRedeems.set(msg.guid, msg);

if (!this.isConnected()) {
reject(`Redeemed without active connection`);
return;
}
this.resultHandlers.set(msg.guid, resolve);

Expand Down
2 changes: 1 addition & 1 deletion ebs/src/modules/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ app.post("/public/transaction", async (req, res) => {
}
]
}).then();
res.status(500).send(`Failed to redeem - ${error}`);
res.status(500).send(`Failed to process redeem - ${error}`);
}
});

Expand Down

0 comments on commit c11089d

Please sign in to comment.