Skip to content

Commit

Permalink
fix: Fix undefined ping/pong module on client-side
Browse files Browse the repository at this point in the history
  • Loading branch information
yeskiy committed Jan 23, 2023
1 parent b771427 commit fb27eb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
11 changes: 0 additions & 11 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ module.exports = class RPCClient {
`Server ready message received`
);

this.websocket.addEventListener("pong", () => {
this.logger.silly(`Pong received`);
setTimeout(() => {
this.websocket.ping();
this.logger.silly(`Ping sent`);
}, 500);
});

this.websocket.ping();
this.logger.silly(`Initial Ping sent`);

this.websocket.sessionId = this.key;
const universalSession = new UniversalRPC(
this.websocket,
Expand Down
15 changes: 10 additions & 5 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,23 @@ module.exports = class RPCServer extends EventEmitter {
);
this.logger.silly("Removed init message listener");

websocketConnection.addEventListener("ping", () => {
this.logger.silly("Ping Received");
websocketConnection.pong();
this.logger.silly("Pong sent");
websocketConnection.on("pong", () => {
this.logger.silly("Pong Received");
setTimeout(() => {
websocketConnection.ping();
this.logger.silly("Ping sent");
}, 500);
});
this.logger.silly("Added ping listener");
this.logger.silly("Added pong listener");

websocketConnection.send({
type: "ready",
data: { key },
});

websocketConnection.ping();
this.logger.silly("Initial Ping sent");

this.logger.silly(
`[${keyPart}] Sent ready message`
);
Expand Down

0 comments on commit fb27eb8

Please sign in to comment.