private OperationResponse ItemOperationSetProperties(Item item, SetProperties operation, SendParameters sendParameters)
        {
            MethodReturnValue result = this.CheckAccess(item);

            if (result.IsOk)
            {
                item.SetProperties(operation.PropertiesSet, operation.PropertiesUnset);
                var eventInstance = new ItemPropertiesSet
                {
                    ItemId             = item.Id,
                    PropertiesRevision = item.PropertiesRevision,
                    PropertiesSet      = operation.PropertiesSet,
                    PropertiesUnset    = operation.PropertiesUnset
                };

                var eventData = new EventData((byte)EventCode.ItemPropertiesSet, eventInstance);
                sendParameters.ChannelId = Settings.ItemEventChannel;
                var message = new ItemEventMessage(item, eventData, sendParameters);
                item.EventChannel.Publish(message);

                // no response sent
                operation.OnComplete();
                return(null);
            }

            return(operation.GetOperationResponse(result));
        }
Esempio n. 2
0
        private OperationResponse ItemOperationSubscribeItem(Item item, SubscribeItem operation, InterestArea interestArea, MmoActor actor)
        {
            if (item.Disposed)
            {
                return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound"));
            }

            lock (interestArea.SyncRoot) {
                interestArea.SubscribeItem(item);
            }

            if (operation.PropertiesRevision.HasValue == false || operation.PropertiesRevision.Value != item.properties.propertiesRevision)
            {
                var properties = new ItemPropertiesSet {
                    ItemId             = item.Id,
                    ItemType           = item.Type,
                    PropertiesRevision = item.properties.propertiesRevision,
                    PropertiesSet      = item.properties.raw
                };
                var eventData = new EventData((byte)EventCode.ItemPropertiesSet, properties);
                actor.Peer.SendEvent(eventData, new SendParameters {
                    ChannelId = Settings.ItemEventChannel
                });
            }

            // don't send response
            operation.OnComplete();
            return(null);
        }
        private OperationResponse ItemOperationSubscribeItem(Item item, SubscribeItem operation)
        {
            if (item.Disposed)
            {
                return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound"));
            }

            this.interestItems.SubscribeItem(item);

            var subscribeEvent = new ItemSubscribed
            {
                ItemId             = item.Id,
                ItemType           = item.Type,
                Position           = item.Position,
                PropertiesRevision = item.PropertiesRevision,
                Rotation           = item.Rotation
            };

            var eventData = new EventData((byte)EventCode.ItemSubscribed, subscribeEvent);

            this.Peer.SendEvent(eventData, new SendParameters {
                ChannelId = Settings.ItemEventChannel
            });

            if (operation.PropertiesRevision.HasValue == false || operation.PropertiesRevision.Value != item.PropertiesRevision)
            {
                var properties = new ItemPropertiesSet
                {
                    ItemId             = item.Id,
                    PropertiesRevision = item.PropertiesRevision,
                    PropertiesSet      = new Hashtable(item.Properties)
                };
                var propEventData = new EventData((byte)EventCode.ItemPropertiesSet, properties);
                this.Peer.SendEvent(propEventData, new SendParameters {
                    ChannelId = Settings.ItemEventChannel
                });
            }

            // don't send response
            operation.OnComplete();
            return(null);
        }