/// <summary> /// Handler for the event ChangedAttribute event in the Entity. Update local sync info for the attribute and /// invokes changedAttributes method on the connected sync nodes to notify them about the change. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event arguments.</param> internal void HandleLocalChangedAttribute(object sender, ChangedAttributeEventArgs e) { var componentName = e.Component.Name; var attributeName = e.AttributeName; // Ignore this change if it was caused by the scalability plugin itself. lock (ignoredAttributeChanges) { var attributeUpdate = new AttributeUpdate(e.Entity.Guid, componentName, attributeName, e.NewValue); if (ignoredAttributeChanges.Remove(attributeUpdate)) { return; } } var newAttributeSyncInfo = new AttributeSyncInfo(ServerSync.LocalServer.SyncID.ToString(), e.NewValue); lock (syncInfo) { if (!syncInfo.ContainsKey(e.Entity.Guid)) { logger.Warn("Local attribute changed in an entity which has no sync info."); return; } EntitySyncInfo entitySyncInfo = syncInfo[e.Entity.Guid]; entitySyncInfo[componentName][attributeName] = newAttributeSyncInfo; } var changedAttributes = new EntitySyncInfo(); changedAttributes[componentName][attributeName] = newAttributeSyncInfo; foreach (IRemoteServer server in ServerSync.RemoteServers) { if (server.DoI.IsInterestedInAttributeChange(e.Entity, e.Component.Name, e.AttributeName)) { server.Connection["serverSync.changeAttributes"](e.Entity.Guid.ToString(), changedAttributes); } } }
/// <summary> /// Handler for the event ChangedAttribute event in the Entity. Update local sync info for the attribute and /// invokes changedAttributes method on the connected sync nodes to notify them about the change. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event arguments.</param> internal void HandleLocalChangedAttribute(object sender, ChangedAttributeEventArgs e) { var componentName = e.Component.Name; var attributeName = e.AttributeName; // Ignore this change if it was caused by the scalability plugin itself. lock (ignoredAttributeChanges) { var attributeUpdate = new AttributeUpdate(e.Entity.Guid, componentName, attributeName, e.NewValue); if (ignoredAttributeChanges.Remove(attributeUpdate)) return; } var newAttributeSyncInfo = new AttributeSyncInfo(ServerSync.LocalServer.SyncID, e.NewValue); lock (syncInfo) { if (!syncInfo.ContainsKey(e.Entity.Guid)) { logger.Warn("Local attribute changed in an entity which has no sync info."); return; } EntitySyncInfo entitySyncInfo = syncInfo[e.Entity.Guid]; entitySyncInfo[componentName][attributeName] = newAttributeSyncInfo; } var changedAttributes = new EntitySyncInfo(); changedAttributes[componentName][attributeName] = newAttributeSyncInfo; foreach (IRemoteServer server in ServerSync.RemoteServers) if (server.DoI.IsInterestedInAttributeChange(e.Entity, e.Component.Name, e.AttributeName)) server.Connection["serverSync.changeAttributes"](e.Entity.Guid, changedAttributes); }