add client-server updateCounter support to sync all persisted rooms
This commit is contained in:
@@ -46,6 +46,18 @@ export default class BinaryDecoder {
|
||||
return this.uint8arr.length
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read `len` bytes as an ArrayBuffer.
|
||||
*/
|
||||
readArrayBuffer (len) {
|
||||
const arrayBuffer = new Uint8Array(len)
|
||||
const view = new Uint8Array(this.uint8arr.buffer, this.pos, len)
|
||||
arrayBuffer.set(view)
|
||||
this.pos += len
|
||||
return arrayBuffer.buffer
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip one byte, jump to the next position.
|
||||
*/
|
||||
|
||||
@@ -181,9 +181,13 @@ export default class BinaryEncoder {
|
||||
* @param encoder The BinaryEncoder to be written.
|
||||
*/
|
||||
writeBinaryEncoder (encoder) {
|
||||
this.writeArrayBuffer(encoder.createBuffer())
|
||||
}
|
||||
|
||||
writeArrayBuffer (arrayBuffer) {
|
||||
const prevBufferLen = this._currentBuffer.length
|
||||
this._data.push(new Uint8Array(this._currentBuffer.buffer, 0, this._currentPos))
|
||||
this._data.push(new Uint8Array(encoder.createBuffer()))
|
||||
this._data.push(new Uint8Array(arrayBuffer))
|
||||
this._currentBuffer = new Uint8Array(prevBufferLen)
|
||||
this._currentPos = 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user