@game-vir/multiplayer - v15.1.1
    Preparing search index...

    Class WebrtcController<MessageData>

    A single peer-to-peer WebRTC controller. It is to be used like this:

    1. Call WebrtcController.createOffer to start off a WebRTC handshake. Send this offer to another WebRTC connection or WebrtcController instance.
    2. Call WebrtcController.createAnswer to accept someone else's WebRTC handshake offer and create a WebRTC handshake answer. Send this answer back to whoever sent the WebRTC offer.
    3. Call WebrtcController.acceptAnswer on the WebrtcController instance that first created the offer.

    If everything went well, after those 3 steps you'll now have a live WebRTC connection!

    Type Parameters

    • MessageData extends JsonCompatibleValue

    Hierarchy

    Index

    Constructors

    Properties

    clientId: `${string}-${string}-${string}-${string}-${string}`
    isConnected: boolean = false

    Indicates whether the WebRTC connection is live or not.

    Methods

    • Accepts a WebRTC answer. This is the third (and last) step in the WebRTC handshake process.

      Parameters

      • rawAnswer: string | Readonly<RTCSessionDescriptionInit>

      Returns Promise<void>

    • Accepts a WebRTC offer and creates a WebRTC answer. This is the second step in the WebRTC handshake process.

      Parameters

      • rawOffer: string | Readonly<RTCSessionDescriptionInit>
      • stunServerUrls: readonly string[]

      Returns Promise<{ sdp: string; type: Answer }>

    • Create a WebRTC offer. This is the first step in the WebRTC handshake process.

      Parameters

      • stunServerUrls: readonly string[]

      Returns Promise<{ sdp: string; type: Offer }>