Ejemplo n.º 1
0
        public void UnSet(string key, BaseProtocol pFrom = null)
        {
            if (!_versionIncremented)
            {
                Version++;
                _versionIncremented = true;
            }
            Payload[key] = null;
            var deleteDirtyInfo = new DirtyInfo {
                PropertyName = key, Type = Defines.SOT_SC_DELETE_DATA
            };

            Synchronization?.Invoke(deleteDirtyInfo);
#if PARALLEL
            _dirtyPropsByProtocol.AsParallel().ForAll(x => x.Value.Add(new DirtyInfo {
                PropertyName = key, Type = Defines.SOT_SC_DELETE_DATA
            }));
#else
            if (pFrom is BaseClusterProtocol)
            {
                foreach (var registeredProtocol in _dirtyPropsByProtocol.Where(x => x.Key != pFrom))
                {
                    registeredProtocol.Value.Add(deleteDirtyInfo);
                }
            }
            else
            {
                foreach (var registeredProtocol in _dirtyPropsByProtocol)
                {
                    registeredProtocol.Value.Add(deleteDirtyInfo);
                }
            }
#endif
        }
Ejemplo n.º 2
0
        public void Clear(BaseProtocol pFrom = null)
        {
            Payload.SetValue();
            var clearDirtyInfo = new DirtyInfo {
                PropertyName = null, Type = Defines.SOT_SC_CLEAR_DATA
            };

            Synchronization?.Invoke(clearDirtyInfo);
            foreach (var registeredProtocol in _dirtyPropsByProtocol.Where(x => x.Key != pFrom))
            {
                registeredProtocol.Value.Add(clearDirtyInfo);
            }
        }
 public void OnAppListSynchronization(DirtyInfo dirty)
 {
     if (dirty.Type == Defines.SOT_SC_UPDATE_DATA &&  Application.SOManager["appList"][dirty.PropertyName] != null)
     {
         var appId = Application.SOManager["appList"][dirty.PropertyName];
         Logger.INFO("sync applist:{0},{1}", dirty.PropertyName, appId);
         ClientApplicationManager.GetOrCreateRoom(dirty.PropertyName, appId);
         if (GotAppIdTasks.ContainsKey(dirty.PropertyName))
         {
             GotAppIdTasks[dirty.PropertyName](appId);
         }
     }
 }
Ejemplo n.º 4
0
        public Variant Set(string key, Variant value, BaseProtocol pFrom = null)
        {
            if (value == null || value == VariantType.Null)
            {
                UnSet(key);
                return(value);
            }
            if (!_versionIncremented)
            {
                Version++;
                _versionIncremented = true;
            }
            Payload[key] = value;
            var updateDirtyInfo = new DirtyInfo {
                PropertyName = key, Type = Defines.SOT_SC_UPDATE_DATA
            };

            Synchronization?.Invoke(updateDirtyInfo);
#if PARALLEL
            _dirtyPropsByProtocol.AsParallel().ForAll(x => x.Value.Add(new DirtyInfo {
                PropertyName = key, Type = x.Key == protocolId ? Defines.SOT_SC_UPDATE_DATACK : Defines.SOT_SC_UPDATE_DATA
            }));
#else
            foreach (var registeredProtocol in _dirtyPropsByProtocol)
            {
                if (registeredProtocol.Key == pFrom)
                {
                    if (pFrom is BaseClusterProtocol)
                    {
                        continue;
                    }
                    registeredProtocol.Value.Add(new DirtyInfo
                    {
                        PropertyName = key,
                        Type         = Defines.SOT_SC_UPDATE_DATA_ACK
                    });
                }
                else
                {
                    registeredProtocol.Value.Add(updateDirtyInfo);
                }
            }
#endif
            return(Payload[key]);
        }
Ejemplo n.º 5
0
 public void Clear(BaseProtocol pFrom = null)
 {
     Payload.SetValue();
     var clearDirtyInfo = new DirtyInfo {PropertyName = null, Type = Defines.SOT_SC_CLEAR_DATA};
     Synchronization?.Invoke(clearDirtyInfo);
     foreach (var registeredProtocol in _dirtyPropsByProtocol.Where(x => x.Key != pFrom))
     {
         registeredProtocol.Value.Add(clearDirtyInfo);
     }
 }
Ejemplo n.º 6
0
        public void UnSet(string key, BaseProtocol pFrom = null)
        {
            if (!_versionIncremented)
            {
                Version++;
                _versionIncremented = true;
            }
            Payload[key] = null;
            var deleteDirtyInfo = new DirtyInfo {PropertyName = key, Type = Defines.SOT_SC_DELETE_DATA};
            Synchronization?.Invoke(deleteDirtyInfo);
#if PARALLEL
            _dirtyPropsByProtocol.AsParallel().ForAll(x => x.Value.Add(new DirtyInfo { PropertyName = key, Type = Defines.SOT_SC_DELETE_DATA }));
#else
            if (pFrom is BaseClusterProtocol)
            {
                foreach (var registeredProtocol in _dirtyPropsByProtocol.Where(x => x.Key != pFrom))
                {
                    registeredProtocol.Value.Add(deleteDirtyInfo);
                }
            }else
                foreach (var registeredProtocol in _dirtyPropsByProtocol)
                {
                     registeredProtocol.Value.Add(deleteDirtyInfo);
                }
#endif
        }
Ejemplo n.º 7
0
        public Variant Set(string key, Variant value, BaseProtocol pFrom = null)
        {
            if (value == null || value == VariantType.Null)
            {
                UnSet(key);
                return value;
            }
            if (!_versionIncremented)
            {
                Version++;
                _versionIncremented = true;
            }
            Payload[key] = value;
            var updateDirtyInfo = new DirtyInfo {PropertyName = key, Type = Defines.SOT_SC_UPDATE_DATA};
            Synchronization?.Invoke(updateDirtyInfo);
#if PARALLEL
            _dirtyPropsByProtocol.AsParallel().ForAll(x => x.Value.Add(new DirtyInfo { PropertyName = key, Type =x.Key == protocolId ? Defines.SOT_SC_UPDATE_DATACK : Defines.SOT_SC_UPDATE_DATA} ));
#else

            foreach (var registeredProtocol in _dirtyPropsByProtocol)
            {
                if (registeredProtocol.Key == pFrom)
                {
                    if (pFrom is BaseClusterProtocol)continue;
                    registeredProtocol.Value.Add(new DirtyInfo
                    {
                        PropertyName = key,
                        Type = Defines.SOT_SC_UPDATE_DATA_ACK
                    });
                }
                else
                {
                    registeredProtocol.Value.Add(updateDirtyInfo);
                }
            }
#endif
            return Payload[key];
        }