Class PluginAbstract

Represents a base plugin for Hindenburg. Should not be extended directly, see WorkerPlugin and RoomPlugin to choose the scope of the plugin.

Needs to be decorated with HindenburgPlugin to actually be able to be imported and loaded.

Hierarchy

Properties

baseDirectory: string

The base directory of the plugin.

The metadata for the plugin, as passed into HindenburgPlugin.

packageJson: PluginPackageJson

The package.json of this plugin.

baseDirectory: string

The directory of the plugin.

config: any

The config passed into this plugin, usually by the config.json on the server.

logger: Logger

A console logger for the plugin.

The metadata for the plugin, as passed into HindenburgPlugin.

packageJson: PluginPackageJson

The package.json associated with this plugin.

Methods

  • Method that is called when the plugin's config updates. You can use this to verify configuration, or just to do something such as switch ports or change authentication when the config changes.

    Parameters

    • oldConfig: any
    • newConfig: any

    Returns any

  • Asynchronous method that is called when the plugin is first loaded into the worker or a room, useful for connecting to any servers or loading large amounts of data before the plugin can actually be used, as the server will wait for it to finish.

    Example

    .@HindenburgPlugin("hbplugin-my-plugin")
    export class MyPlugin extends WorkerPlugin {
    async onPluginLoad() {
    const res = await fetch("https://icanhazip.com/");
    const ip = await res.text();

    console.log("My ip is " + ip);
    }
    }

    Returns any

  • Method that is called when the plugin is unloaded from the worker or room, useful for destroying any connections to any servers, clearing up extra event listeners to prevent memory leaks, or closing any server sockets.

    Not called when the server shuts down, and the server also does not wait for it to finish.

    Example

    .@HindenburgPlugin("hbplugin-my-plugin")
    export class MyPlugin extends WorkerPlugin {
    async onPluginUnload() {
    this.logger.info("Closing socket..");
    await this.socket.close();
    this.logger.info("Closed socket");
    }
    }

    Returns any

Generated using TypeDoc