@evitcastudio/kit
Version:
A single-player/multiplayer framework for the Vylocity Game Engine.
55 lines • 2.16 kB
TypeScript
import { KitPlugin } from '../kit-plugin';
import type { Client } from '../../types/vylo.d.ts';
export type NetworkListener<T extends unknown[] = unknown[]> = (pClient: Client, ...pData: T) => void;
export declare class Network extends KitPlugin {
name: string;
/**
* If this plugin is initiated.
*/
private initiated;
/**
* The packets that this plugin has registered. It is in the format of name: index
*/
private packets;
/**
* The packets that this plugin has registered. It is in the format of index: name
*/
private reversedPacketMap;
onRegistered(): void;
/**
* The listeners that are registered.
*/
private listeners;
/**
* Register a listener for a packet.
* @param pPacketName - The name of the packet that will be listened to.
* @param pListener - The listener that will be called when the packet is received.
*/
onPacket<T extends unknown[]>(pPacketName: string, pListener: NetworkListener<T>): void;
/**
* Register a listener for a packet.
* @deprecated Use `onPacket` instead.
* @param pPacketName - The name of the packet that will be listened to.
* @param pListener - The listener that will be called when the packet is received.
*/
on<T extends unknown[]>(pPacketName: string, pListener: NetworkListener<T>): void;
/**
* API for receiving data from the server.
* @param pClient - The client involved with this packet.
* @param pPacketName - The name of the packet that was sent.
* @param pData - The data that was sent.
* @param [pVerbose] - If the plugin should log packets.
*/
onNetwork(pClient: Client, pPacketName: number | string, pData?: unknown[], pVerbose?: boolean): void;
/**
* Register the packets registry.
* @param pPackets - An array of strings that represent the packet names.
*/
registerPackets(pPackets: readonly string[]): void;
/**
* Gets the index of a packet.
* @param pPacketName - The name of the packet.
*/
getPacket(pPacketName: string): number | undefined;
}
//# sourceMappingURL=index.d.ts.map