Skip to content

Commit

Permalink
fix rate at which multiplayer images are sent to 20fps (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwunderl authored Oct 19, 2022
1 parent d6a3d6d commit f9de8f5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/game/sim/multiplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ namespace pxsim {
state: "Pressed" | "Released" | "Held";
}

let postScreenInterval: any;
export class MultiplayerState {
lastMessageId: number;
origin: string;
backgroundImage: RefImage;


constructor() {
this.lastMessageId = 0;
}
Expand All @@ -74,7 +76,10 @@ namespace pxsim {
init(origin: string) {
this.origin = origin;
runtime.board.addMessageListener(msg => this.messageHandler(msg));
setInterval(() => {
if (postScreenInterval) {
clearInterval(postScreenInterval)
}
postScreenInterval = setInterval(() => {
if (this.origin === "server") {
const b = board() as ScreenBoard;
const screenState = b && b.screenState;
Expand Down

0 comments on commit f9de8f5

Please sign in to comment.