Nocturna
    Preparing search index...

    NetworkManager handles all networking for multiplayer, including:

    • WebSocket connection to the signaling server for lobby management and WebRTC signaling.
    • Room creation, joining, and participant management.
    • Peer-to-peer connection setup using WebRTC (offers, answers, ICE candidates).
    • Sending and receiving game updates between participants.
    • Notifying observers of network events.

    Implements the singleton pattern: use NetworkManager.getInstance() to get the instance.

    Implements

    Index

    Properties

    ANSWER_CMD: "answer"
    ROOM_PARTICIPANTS_CMD: "room_participants"

    Methods

    • Creates a WebSocket connection to the given URL.

      Parameters

      • url: string

        The WebSocket server URL.

      Returns void

    • Sends a request to join an existing room.

      Parameters

      • roomId: string

        The room ID to join.

      • playerId: string

        The player's ID.

      Returns void

    • Sends a WebRTC answer to a remote participant via the signaling server.

      Parameters

      • remoteId: string

        The remote participant's ID.

      • answer: RTCSessionDescriptionInit

        The RTC session description answer.

      Returns void

    • Sends an ICE candidate to a remote participant via the signaling server.

      Parameters

      • remoteId: string

        The remote participant's ID.

      • candidate: RTCIceCandidateInit

        The ICE candidate.

      Returns void

    • Sends a WebRTC offer to a remote participant via the signaling server.

      Parameters

      • remoteId: string

        The remote participant's ID.

      • offer: RTCSessionDescriptionInit

        The RTC session description offer.

      Returns void

    • Sends a game update to all remote participants via their data channels.

      Parameters

      • action: string

        The action type.

      • data: any

        The data payload.

      Returns void