Skip to content

[Feature Request] synced lobbyTime #61

Description

@afrokick

Hey!

Motivation:

Almost every multiplayer online game has a synced clock aka remoteTime, remoteTicks, roomTime etc.

Its helps to understand when exactly actions be happened and how to handle it on the local side.

Suggestion:

When we create a lobby, we set on the server side:

_createdAt = Date.now();
lobbyTime(){
  return Date.now() - _createdAt;
}

Then, we send it to the every peer.

On the client side, we have:
network.ts

  private onLobbyTimeReceived(lobbyTime: number) {
    // TODO we need to compensate for the RTT/ping
    const compensation = 10;
    this._createdAt = Date.now() - lobbyTime + compensation;
    
  }
  get lobbyTime() {
    return Date.time() - this._createdAt;
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions