@xmcl/client
Version:
Minecraft socket pipeline utilities. Support Minecraft lan server discovery.
37 lines • 1.5 kB
TypeScript
import { State } from './channel';
import { Coder } from './coders';
export type Side = 'server' | 'client';
export interface PacketRegistryEntry {
readonly id: number;
readonly name: string;
readonly state: State;
readonly side: Side;
readonly coder: Coder<any>;
}
export type FieldType<T> = (type: Coder<T>) => (target: any, key: string) => void;
export type PacketType = (side: Side, id: number, state: State) => (constructor: Function) => void;
export declare const PacketMetadata: unique symbol;
export declare const PacketFieldsMetadata: unique symbol;
/**
* Get a packet registry entry for a class
* @param clazz The class object
*/
export declare function getPacketRegistryEntry(clazz: new (...args: any) => any): PacketRegistryEntry;
/**
* Annotate the field type in your packet. Assign a coder for serialization/deserialization.
* This will generate a list of `FieldType` in your class prototype.
*
* @param type The coder to serialize/deserialize the field.
* @see "coders.ts"
*/
export declare function Field<T>(type: Coder<T>): (target: any, key: string) => void;
/**
* Decoarte for you packet class.
* This will generate a `PacketRegistryEntry` in your class prototype.
*
* @param side The side of your packet
* @param id The id of your packet
* @param state The state of you packet should be
*/
export declare function Packet(side: Side, id: number, state: State, name?: string): (constructor: Function) => void;
//# sourceMappingURL=packet.d.ts.map