Class SocketManager

    Manages socket-level communication and exposes helper methods/events for interacting with the Archipelago API directly.

    Hierarchy

    Accessors

    Methods

    • Establish a connection to an Archipelago server before authenticating; useful if there might be tasked that are needed to be performed before authenticating, but after connecting (e.g., DataPackage).

      Parameters

      • url: string | URL

        The url of the server, including the protocol (e.g., wss://archipelago.gg:38281).

      Returns Promise<RoomInfoPacket>

      The RoomInfoPacket received on initial connection.

      SocketError if failed to connect or no websocket API is available.

      TypeError if provided URL is malformed or invalid protocol.

      If the port is omitted, client will default to 38281.

      If the protocol is omitted, client will attempt to connect via wss, then fallback to ws if unsuccessful.

    • Removes an existing event listener.

      Type Parameters

      • Event extends
            | "disconnected"
            | "connected"
            | "bounced"
            | "connectionRefused"
            | "dataPackage"
            | "invalidPacket"
            | "locationInfo"
            | "printJSON"
            | "receivedItems"
            | "retrieved"
            | "roomInfo"
            | "roomUpdate"
            | "setReply"
            | "receivedPacket"
            | "sentPackets"

      Parameters

      • event: Event

        The event name associated with this listener to remove.

      • listener: ((...args: SocketEvents[Event]) => void)

        The callback function to remove.

      Returns this

      This object.

    • Add an event listener for a specific event.

      Type Parameters

      • Event extends
            | "disconnected"
            | "connected"
            | "bounced"
            | "connectionRefused"
            | "dataPackage"
            | "invalidPacket"
            | "locationInfo"
            | "printJSON"
            | "receivedItems"
            | "retrieved"
            | "roomInfo"
            | "roomUpdate"
            | "setReply"
            | "receivedPacket"
            | "sentPackets"

      Parameters

      • event: Event

        The event name to listen for.

      • listener: ((...args: SocketEvents[Event]) => void)

        The callback function to fire when this event is received.

      Returns this

      This object.

    • Returns a promise that waits for a single specified event to be received. Resolves with the list of arguments dispatched with the event.

      Type Parameters

      • Event extends
            | "disconnected"
            | "connected"
            | "bounced"
            | "connectionRefused"
            | "dataPackage"
            | "invalidPacket"
            | "locationInfo"
            | "printJSON"
            | "receivedItems"
            | "retrieved"
            | "roomInfo"
            | "roomUpdate"
            | "setReply"
            | "receivedPacket"
            | "sentPackets"

      Parameters

      • event: Event

        The event name to listen for.

      • clearPredicate: ((...args: SocketEvents[Event]) => boolean) = ...

        An optional predicate to check on incoming events to validate if the correct event has been received. If omitted, will return immediately on next event type received.

      Returns Promise<SocketEvents[Event]>