skeldjs
    Preparing search index...

    Class LanDiscovery

    Represents the LAN searching for games area in Among Us.

    Binds a UDP socket to 47777 and waits for messages containing a game name and the number of players in the game.

    Prevents duplicate games from repeated broadcast messages.

    See LanDiscoveryEvents for events to listen to.

    (async () => {
    const lanDiscovery = new LanDiscovery;
    const client = new SkeldjsClient("2021.4.25");

    client.on("client.disconnect", disconnect => {
    console.log("Client disconnected: %s", DisconnectReason[disconnect.reason]);
    });

    lanDiscovery.begin();
    const foundGame = await lanDiscovery.wait("discovery.foundgame");

    await client.connect(foundGame.ip, "weakeyes");

    await client.joinGame(foundGame.gameCode);

    await client.me?.control?.setName("weakeyes");
    await client.me?.control?.setColor(Color.Blue);
    })();

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    All games that have been found so far, cleared on LanDiscovery.begin.

    socket?: Socket

    The UDP socket used.

    Methods

    • Start listening for games hosted locally, binds to 47777. Clears the LanDiscovery.foundGames array.

      Returns Promise<void>

      const lanDiscovery = new LanDiscovery;

      lanDiscovery.begin();

      lanDiscovery.on("discovery.foundgame", foundGame => {
      console.log(`Found game: ${foundGame.name} at ${foundGame.ip}:${foundGame.port}`);
      });
    • Search for games for a specified amount of time. Clears the current LanDiscovery.foundGames array.

      Properly cleans up with LanDiscovery.end afterwards.

      Parameters

      • numSeconds: number

        The number of seconds to search for games for.

      Returns Promise<DiscoveryFoundGameEvent[]>

      The games that were found.

      const lanDiscovery = new LanDiscovery;
      const games = await lanDiscovery.searchFor(5); // search for 5 seconds.

      console.log(games); // => [ DiscoveryFoundGameEvent, DiscoveryFoundGameEvent, ...]