dot big bang

Developer API
Menu

Class Peer

All
  • Public
  • Public/Protected
  • All

A Peer represents a client connected to the Session (i.e. a browser tab open on the dbb game URL). A Peer has a single User associated with it. The User represents the person currently logged under a dbb account or a guest who isn't logged in.

Hierarchy

  • Peer

Index

Properties

Accessors

Methods

Properties

Readonly user

user: User

Returns the User associated with the Peer.

Accessors

id

  • get id(): string
  • The identifier string of the Peer. The id is unique across all the Peers of the Session, there can't be two Peers with the same id. The id isn't persisted or bound to the machine/client, it's assigned at connection time and changes from one Session to the next.

    Returns string

isFocused

  • get isFocused(): boolean
  • Indicates whether the Peer's browser window is focused or not

    Returns boolean

isLocal

  • get isLocal(): boolean
  • Indicates whether the Peer represents the local client/machine. A non-local Peer is called a remote Peer.

    Returns boolean

isServer

  • get isServer(): boolean
  • Indicates whether the Peer is the server of the Session. Each Session has a single Peer marked as server. When the Peer leaves the Session another one is automatically designated. The server is responsible for the networked Entities that come with the loaded Game (i.e. the Entities which isNetworked property is true and isSpawned false). Internally, the server is also in charge of providing new Peers joining the Session with the current state of the Game.

    Returns boolean

Methods

ownsEntity

  • ownsEntity(entity: Entity): boolean
  • Indicates whether the Peer owns the given Entity (in the dbb networking-model sense). This is equivalent to entity.isOwnedByPeer(peer)

    Parameters

    Returns boolean