'init'
This commit is contained in:
28
app/providers/ProtocolProvider/protocol/packet.ts
Normal file
28
app/providers/ProtocolProvider/protocol/packet.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import Stream from "./stream";
|
||||
|
||||
/**
|
||||
* Packet abstract class
|
||||
*/
|
||||
export default abstract class Packet {
|
||||
|
||||
/**
|
||||
* Get the packet ID
|
||||
* @returns packet ID
|
||||
*/
|
||||
public abstract getPacketId(): number;
|
||||
/**
|
||||
* Use the stream to read the packet and fill structure
|
||||
* @param stream stream
|
||||
*/
|
||||
public abstract _receive(stream: Stream): void;
|
||||
/**
|
||||
* Use the stream to write the packet and return the stream
|
||||
* @returns stream
|
||||
*/
|
||||
public abstract _send(): Promise<Stream> | Stream;
|
||||
|
||||
public clone(): Packet {
|
||||
return new (this as any).constructor();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user