fix some tests, implement event classes for types, and re-implement logging

This commit is contained in:
Kevin Jahns
2017-10-22 19:12:50 +02:00
parent 755c9eb16e
commit c92f987496
17 changed files with 235 additions and 259 deletions

View File

@@ -28,9 +28,7 @@ function _integrateRemoteStructHelper (y, struct) {
missingDef.missing--
if (missingDef.missing === 0) {
let missing = missingDef.struct._fromBinary(y, missingDef.decoder)
if (missing.length > 0) {
console.error('Missing should be empty!')
} else {
if (missing.length === 0) {
y._readyToIntegrate.push(missingDef.struct)
}
}
@@ -42,6 +40,21 @@ function _integrateRemoteStructHelper (y, struct) {
}
}
export function stringifyStructs (y, decoder, strBuilder) {
while (decoder.length !== decoder.pos) {
let reference = decoder.readVarUint()
let Constr = getStruct(reference)
let struct = new Constr()
let missing = struct._fromBinary(y, decoder)
let logMessage = struct._logString()
if (missing.length > 0) {
logMessage += missing.map(id => `ID (user: ${id.user}, clock: ${id.clock})`).join(', ')
}
logMessage += '\n'
strBuilder.push(logMessage)
}
}
export function integrateRemoteStructs (decoder, encoder, y) {
while (decoder.length !== decoder.pos) {
let decoderPos = decoder.pos