@gwigz/homunculus-core
Version:
A third-party framework for interacting with Linden Lab's virtual world "Second Life"
27 lines (26 loc) • 838 B
TypeScript
import type { Client } from "../client";
import type { Circuit, Core, Packet, PacketMetadata } from "../network";
import type { Region } from "../structures";
export interface DelegateContext {
client: Client;
core: Core;
circuit: Circuit;
region: Region;
}
export interface DelegateConfig<T extends object> {
handle: (packet: Packet<T>, context: DelegateContext) => Promise<any> | any;
skip?: (context: DelegateContext) => boolean;
priority?: number;
metadata: PacketMetadata;
}
export declare class Delegate {
private delegates;
/**
* Register a new packet delegate.
*/
register<T extends object>(config: DelegateConfig<T>): void;
/**
* Gets all delegates that are ready to handle a packet.
*/
get(name: string, context: DelegateContext): DelegateConfig<any>[];
}