Промежуточный этап синхронизации
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import Packet from "../packet";
|
||||
import Stream from "../stream";
|
||||
|
||||
export enum SyncStatus {
|
||||
NOT_NEEDED,
|
||||
BATCH_START,
|
||||
BATCH_END
|
||||
}
|
||||
|
||||
export class PacketSync extends Packet {
|
||||
|
||||
private status : SyncStatus = SyncStatus.NOT_NEEDED;
|
||||
private timestamp : number = 0;
|
||||
|
||||
public getPacketId(): number {
|
||||
return 25; //0x19
|
||||
}
|
||||
|
||||
public _receive(stream: Stream): void {
|
||||
this.status = stream.readInt8() as SyncStatus;
|
||||
this.timestamp = stream.readInt64();
|
||||
}
|
||||
|
||||
public _send(): Promise<Stream> | Stream {
|
||||
let stream = new Stream();
|
||||
stream.writeInt16(this.getPacketId());
|
||||
stream.writeInt8(this.status);
|
||||
stream.writeInt64(this.timestamp);
|
||||
return stream;
|
||||
}
|
||||
|
||||
public getStatus() : SyncStatus {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public setStatus(status: SyncStatus) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public getTimestamp() : number {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
public setTimestamp(timestamp: number) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user