Example #1
0
        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;
            }
        }
Example #2
0
 internal void DeSerializeObjectsAll(NetworkReader reader)
 {
     for (int i = 0; i < syncObjects.Count; i++)
     {
         ISyncObject syncObject = syncObjects[i];
         syncObject.OnDeserializeAll(reader);
     }
 }
Example #3
0
        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);
        }
Example #4
0
 public static void Lock(ISyncObject subject, Action action)
 {
     subject.Lock();
     try
     {
         action();
     }
     finally
     {
         subject.Unlock();
     }
 }
Example #5
0
        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);
                }
            }
        }
Example #6
0
        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);
        }
Example #7
0
        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;
        }
Example #8
0
        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);
        }
Example #9
0
 // 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;
 }
Example #10
0
 // 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);
 }
Example #11
0
 public bool Equals(ISyncObject other)
 {
     return(this.Created.Equals(other.Created) &&
            this.Modified.Equals(other.Modified) &&
            this.Deleted.Equals(other.Deleted));
 }
Example #12
0
 public static void Lock(ISyncObject subject, Action action)
 {
     subject.Lock();
     action();
     subject.Unlock();
 }
Example #13
0
 public bool Equals(ISyncObject other)
 {
     return this.Created.Equals(other.Created) &&
         this.Modified.Equals(other.Modified) &&
         this.Deleted.Equals(other.Deleted);
 }