示例#1
0
 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);
 }
示例#3
0
 private void HandleOnAttributeInComponentChanged(object sender, ChangedAttributeEventArgs e)
 {
     if (e.Component.Name == "scripting")
         InitEntityContext((Entity)sender);
 }
示例#4
0
 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);
        }
示例#6
0
 private void HandleChangedComponentAttribute(object sender, ChangedAttributeEventArgs e)
 {
     if (ChangedAttribute != null)
         ChangedAttribute(this, e);
 }
示例#7
0
 /// <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;
 }
示例#8
0
 /// <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();
     }
 }