Skip to content

[Feature Request] synced lobbyTime #61

@afrokick

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;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions