Skip to content

Commit

Permalink
fix: #dev ping sending fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbator committed Nov 21, 2024
1 parent 5a34eb0 commit 8204cdc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { Game } from '@gameModels/game.class';
>
@if (aiSocketService.getIsSocketConnected()) {
<span
>Ping: <b>{{ aiSocketService.getSocketPing() }}</b></span
>Ping: <b>{{ aiSocketService.getSocketPing() }} ms</b></span
>
<app-socket-connected-menu
[isDataSendingActive]="aiSocketService.getIsDataSendingActive()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class AiSocketService {
this.isDataSendingActive = true;
this._sendingIntervalID = setInterval(() => {
this.sendDataToSocket(this._dataToSend, expectedDataToReceive, playerId);
this.sendPing();
this._lastPingSentTime = Date.now();
}, sendingInterval);
};

Expand Down Expand Up @@ -108,13 +108,6 @@ export class AiSocketService {

//

private sendPing(): void {
if (this._socket && this._socket.readyState === WebSocket.OPEN) {
this._lastPingSentTime = Date.now();
this._socket.send(JSON.stringify({ type: 'ping' }));
}
}

private defineSocket(
socketUrl: string,
onOpen: () => void,
Expand Down

0 comments on commit 8204cdc

Please sign in to comment.