public ZPushSync(ZPushWatcher watcher, IAddIn addIn) { // Get the settings Enabled = GlobalOptions.INSTANCE.ZPushSync; Period = GlobalOptions.INSTANCE.ZPushSync_Period; if (Period.Ticks == 0) { Period = Constants.ZPUSH_SYNC_DEFAULT_PERIOD; } PeriodThrottle = GlobalOptions.INSTANCE.ZPushSync_PeriodThrottle; if (PeriodThrottle.Ticks == 0) { PeriodThrottle = Constants.ZPUSH_SYNC_DEFAULT_PERIOD_THROTTLE; } // Set up a timer and events if enabled if (Enabled) { _watcher = watcher; _timer = new System.Windows.Forms.Timer(); _timer.Interval = (int)Period.TotalMilliseconds; _timer.Tick += _timer_Tick; _timer.Start(); // Need to keep a reference to keep receiving events _syncObject = addIn.GetSyncObject(); _syncObject.SyncEnd += SyncObject_SyncPeriodics; _syncObject.SyncEnd += SyncObject_SyncOneOffTasks; watcher.AccountDiscovered += Watcher_AccountDiscovered; } }
internal void DeSerializeObjectsAll(NetworkReader reader) { for (int i = 0; i < syncObjects.Count; i++) { ISyncObject syncObject = syncObjects[i]; syncObject.OnDeserializeAll(reader); } }
public bool SerializeObjectsAll(NetworkWriter writer) { bool dirty = false; for (int i = 0; i < syncObjects.Count; i++) { ISyncObject syncObject = syncObjects[i]; syncObject.OnSerializeAll(writer); dirty = true; } return(dirty); }
public static void Lock(ISyncObject subject, Action action) { subject.Lock(); try { action(); } finally { subject.Unlock(); } }
internal void DeSerializeObjectsDelta(NetworkReader reader) { ulong dirty = reader.ReadPackedUInt64(); for (int i = 0; i < syncObjects.Count; i++) { ISyncObject syncObject = syncObjects[i]; if ((dirty & (1UL << i)) != 0) { syncObject.OnDeserializeDelta(reader); } } }
internal ulong DirtyObjectBits() { ulong dirtyObjects = 0; for (int i = 0; i < syncObjects.Count; i++) { ISyncObject syncObject = syncObjects[i]; if (syncObject.IsDirty) { dirtyObjects |= 1UL << i; } } return(dirtyObjects); }
public void OnSyncObjReadyChange(ISyncObject sobj, ReadyStateEnum readyState) { int syncObjIndex = sobj.SyncObjIndex; if (readyState != ReadyStateEnum.Unready) { syncObjReadyMask[syncObjIndex] = true; } else { syncObjReadyMask[syncObjIndex] = false; } AllObjsAreReady = syncObjReadyMask.AllAreTrue && packObjReadyMask.AllAreTrue; }
public bool SerializeObjectsDelta(NetworkWriter writer) { bool dirty = false; // write the mask writer.WritePackedUInt64(DirtyObjectBits()); // serializable objects, such as synclists for (int i = 0; i < syncObjects.Count; i++) { ISyncObject syncObject = syncObjects[i]; if (syncObject.IsDirty) { syncObject.OnSerializeDelta(writer); dirty = true; } } return(dirty); }
// this gets called in the constructor by the weaver // for every SyncObject in the component (e.g. SyncLists). // We collect all of them and we synchronize them with OnSerialize/OnDeserialize protected internal void InitSyncObject(ISyncObject syncObject) { syncObjects.Add(syncObject); syncObject.OnChange += SyncObject_OnChange; }
// this gets called in the constructor by the weaver // for every SyncObject in the component (e.g. SyncLists). // We collect all of them and we synchronize them with OnSerialize/OnDeserialize protected void InitSyncObject(ISyncObject syncObject) { syncObjects.Add(syncObject); }
public bool Equals(ISyncObject other) { return(this.Created.Equals(other.Created) && this.Modified.Equals(other.Modified) && this.Deleted.Equals(other.Deleted)); }
public static void Lock(ISyncObject subject, Action action) { subject.Lock(); action(); subject.Unlock(); }
public bool Equals(ISyncObject other) { return this.Created.Equals(other.Created) && this.Modified.Equals(other.Modified) && this.Deleted.Equals(other.Deleted); }