refactor: packet x1
This commit is contained in:
1 parent
af29c17814
commit
7fd94a03b7
105 files changed
+2286
-1962
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { NapProtoDecodeStructType } from "@napneko/nap-proto-core";
|
||||
import { PacketMsgBuilder } from "@/core/packet/message/builder";
|
||||
|
||||
export type PacketHexStr = string & { readonly hexNya: unique symbol };
|
||||
|
||||
export const PacketHexStrBuilder = (str: Uint8Array): PacketHexStr => {
|
||||
return Buffer.from(str).toString('hex') as PacketHexStr;
|
||||
};
|
||||
|
||||
export interface OidbPacket {
|
||||
cmd: string;
|
||||
data: PacketHexStr
|
||||
}
|
||||
|
||||
export abstract class PacketTransformer<T> {
|
||||
protected msgBuilder: PacketMsgBuilder;
|
||||
|
||||
protected constructor() {
|
||||
this.msgBuilder = new PacketMsgBuilder();
|
||||
}
|
||||
|
||||
abstract build(...args: any[]): OidbPacket | Promise<OidbPacket>;
|
||||
|
||||
abstract parse(data: Buffer): NapProtoDecodeStructType<T>;
|
||||
}
|
||||
Reference in new issue
Block a user