src/ServerEngine.js
//       size calculation are done in a single phase, along with string pruning.
size calculation are done in a single phase, along with string pruning.
size calculation are done in a single phase along with string pruning .
serializeUpdate(roomName, object, options) {
        let world = this.gameEngine.world;
        let diffUpdate = Boolean(options && options.diffUpdate);
        let objId = object.id
        let obj = world.objects[objId];
        let prevObject = this.objMemory[objId];
        if (diffUpdate) {
            let s = obj.serialize(this.serializer);
            if (prevObject && Utils.arrayBuffersEqual(s.dataBuffer, prevObject))
                return;
            else
                this.objMemory[objId] = s.dataBuffer;
            obj = obj.prunedStringsClone(this.serializer, prevObject);
        }
        this.networkTransmitter.addNetworkedEvent(roomName, 'objectUpdate', {
            stepCount: world.stepCount,
            objectInstance: obj
        });
    }
serializeUpdate ( roomName , object , options ) { let world = this . gameEngine . world ; let diffUpdate = Boolean ( options && options . diffUpdate ) ; let objId = object . id let obj = world . objects [ objId ] ; let prevObject = this . objMemory [ objId ] ; if ( diffUpdate ) { let s = obj . serialize ( this . serializer ) ; if ( prevObject && Utils . arrayBuffersEqual ( s . dataBuffer , prevObject ) ) return ; else this . objMemory [ objId ] = s . dataBuffer ; obj = obj . prunedStringsClone ( this . serializer , prevObject ) ; } this . networkTransmitter . addNetworkedEvent ( roomName , 'objectUpdate' , { stepCount : world . stepCount , objectInstance : obj } ) ; }
size calculation are done in a single phase, along with string pruning.
size calculation are done in a single phase along with string pruning .
// if the object (in serialized form) hasn't changed, move on // prune strings which haven't changed