private void HandleChangedComponentAttribute(object sender, ChangedAttributeEventArgs e) { if (ChangedAttribute != null) { ChangedAttribute(this, e); } }
/// <summary> /// Event Handler for AttributeInComponentChanged on Entity. When fired, the value update is queued to be persisted on the next persistence /// save to the database /// </summary> /// <param name="sender">Sender of the event (the Entity)</param> /// <param name="e">Event arguments</param> internal void OnAttributeChanged(Object sender, ChangedAttributeEventArgs e) { Guid changedAttributeGuid = e.Component.Definition[e.AttributeName].Guid; AddAttributeToPersisted (e.Component.Guid, e.AttributeName, e.NewValue); }
private void HandleOnAttributeInComponentChanged(object sender, ChangedAttributeEventArgs e) { if (e.Component.Name == "scripting") InitEntityContext((Entity)sender); }
void HandleChangedAvatarComponent(object sender, ChangedAttributeEventArgs e) { if (e.AttributeName == "userLogin") { if (e.OldValue != null && avatarEntities.ContainsKey((string)e.OldValue)) avatarEntities.Remove((string)e.OldValue); avatarEntities[(string)e.NewValue] = e.Entity; } }
/// <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); }
private void HandleChangedComponentAttribute(object sender, ChangedAttributeEventArgs e) { if (ChangedAttribute != null) ChangedAttribute(this, e); }
/// <summary> /// Creates the update info from event arguments. /// </summary> /// <returns>The update info from event arguments.</returns> /// <param name="entityGuid">GUID of the entity triggering the AttributeChanged event</param> /// <param name="e">Event arguments</param> private UpdateInfo CreateUpdateInfoFromEventArgs(Entity entity, ChangedAttributeEventArgs e) { UpdateInfo newUpdateInfo = new UpdateInfo(); newUpdateInfo.entityGuid = entity.Guid.ToString(); newUpdateInfo.componentName = e.Component.Name; newUpdateInfo.attributeName = e.AttributeName; newUpdateInfo.value = e.NewValue; return newUpdateInfo; }
/// <summary> /// Adds update information about an entity to the update queue after having received an attributeChanged event /// </summary> /// <param name="sender">Entity that invoked the attribute change event</param> /// <param name="e">Event Arguments</param> private void AddEntityUpdateToQueue(Object sender, ChangedAttributeEventArgs e) { bool gotLock = false; try { QueueLock.Enter(ref gotLock); UpdateQueue.Add(CreateUpdateInfoFromEventArgs((Entity)sender, e)); } finally { if (gotLock) QueueLock.Exit(); } }