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));
        }
Exemple #2
0
        private void PublishUpdate(Item item, Vector position, bool remove, bool unreliable)
        {
            var        updateEvent = GetUpdateEvent(item, position, remove);
            IEventData eventData   = new EventData((byte)EventCode.RadarUpdate, updateEvent);
            var        message     = new ItemEventMessage(item, eventData, new SendParameters {
                Unreliable = unreliable, ChannelId = Settings.RadarEventChannel
            });

            this.channel.Publish(message);
        }
Exemple #3
0
        /// <summary>
        /// Publishes event ItemDestroyed in the Item.EventChannel.
        /// </summary>
        protected void OnDestroy()
        {
            var eventInstance = new ItemDestroyed {
                ItemId = this.Id
            };
            var eventData = new EventData((byte)EventCode.ItemDestroyed, eventInstance);
            var message   = new ItemEventMessage(this, eventData, new SendParameters {
                ChannelId = Settings.ItemEventChannel
            });

            this.EventChannel.Publish(message);
        }
        private static OperationResponse ItemOperationRaiseGenericEvent(Item item, RaiseGenericEvent operation, SendParameters sendParameters)
        {
            if (item.Disposed)
            {
                return(operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound"));
            }

            var eventInstance = new ItemGeneric
            {
                ItemId          = item.Id,
                CustomEventCode = operation.CustomEventCode,
                EventData       = operation.EventData
            };

            var eventData = new EventData((byte)EventCode.ItemGeneric, eventInstance);

            sendParameters.Unreliable = (Reliability)operation.EventReliability == Reliability.Unreliable;
            sendParameters.ChannelId  = Settings.ItemEventChannel;
            switch (operation.EventReceiver)
            {
            case (byte)EventReceiver.ItemOwner:
            {
                item.Owner.Peer.SendEvent(eventData, sendParameters);
                break;
            }

            case (byte)EventReceiver.ItemSubscriber:
            {
                var message = new ItemEventMessage(item, eventData, sendParameters);
                item.EventChannel.Publish(message);
                break;
            }

            default:
            {
                return(operation.GetOperationResponse((int)ReturnCode.ParameterOutOfRange, "Invalid EventReceiver " + operation.EventReceiver));
            }
            }

            // no response
            operation.OnComplete();
            return(null);
        }
        private OperationResponse ItemOperationMove(Item item, Move operation, SendParameters sendParameters)
        {
            // should always be OK
            MethodReturnValue result = this.CheckAccess(item);

            if (result.IsOk)
            {
                // save previous for event
                Vector oldPosition = item.Position;
                Vector oldRotation = item.Rotation;

                // move
                item.Rotation = operation.Rotation;
                item.Move(operation.Position);

                // send event
                var eventInstance = new ItemMoved
                {
                    ItemId      = item.Id,
                    OldPosition = oldPosition,
                    Position    = operation.Position,
                    Rotation    = operation.Rotation,
                    OldRotation = oldRotation
                };

                var eventData = new EventData((byte)EventCode.ItemMoved, 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));
        }
 private static void RadarChannel_OnItemEventMessage(PeerBase peer, ItemEventMessage message)
 {
     // already in right fiber, we would use peer.SendEvent otherwise
     peer.SendEvent(message.EventData, message.SendParameters);
 }
        private OperationResponse ItemOperationMove(Item item, Move operation, SendParameters sendParameters)
        {
            // should always be OK
            MethodReturnValue result = this.CheckAccess(item);
            if (result.IsOk)
            {
                // save previous for event
                Vector oldPosition = item.Position;
                Vector oldRotation = item.Rotation;

                // move
                item.Rotation = operation.Rotation;
                item.Move(operation.Position);

                // send event
                var eventInstance = new ItemMoved
                    {
                        ItemId = item.Id,
                        OldPosition = oldPosition,
                        Position = operation.Position,
                        Rotation = operation.Rotation,
                        OldRotation = oldRotation
                    };

                var eventData = new EventData((byte)EventCode.ItemMoved, 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);
        }
        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);
        }
Exemple #9
0
 /// <summary>
 ///   Sends the event to the client.
 /// </summary>
 /// <param name = "peer">
 ///   The client peer.
 /// </param>
 /// <param name = "message">
 ///   The message.
 /// </param>
 private static void RadarChannel_OnItemEventMessage(PeerBase peer, ItemEventMessage message)
 {
     // already in right fiber, we would use peer.SendEvent otherwise
     peer.SendEvent(message.EventData, message.SendParameters);
 }
        private static OperationResponse ItemOperationRaiseGenericEvent(Item item, RaiseGenericEvent operation, SendParameters sendParameters)
        {
            if (item.Disposed)
            {
                return operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound");
            }

            var eventInstance = new ItemGeneric
            {
                ItemId = item.Id,
                CustomEventCode = operation.CustomEventCode,
                EventData = operation.EventData
            };

            var eventData = new EventData((byte)EventCode.ItemGeneric, eventInstance);
            sendParameters.Unreliable = (Reliability)operation.EventReliability == Reliability.Unreliable;
            sendParameters.ChannelId = Settings.ItemEventChannel;
            switch (operation.EventReceiver)
            {
                case (byte)EventReceiver.ItemOwner:
                    {
                        item.Owner.Peer.SendEvent(eventData, sendParameters);
                        break;
                    }

                case (byte)EventReceiver.ItemSubscriber:
                    {
                        var message = new ItemEventMessage(item, eventData, sendParameters);
                        item.EventChannel.Publish(message);
                        break;
                    }

                default:
                    {
                        return operation.GetOperationResponse((int)ReturnCode.ParameterOutOfRange, "Invalid EventReceiver " + operation.EventReceiver);
                    }
            }

            // no response
            operation.OnComplete();
            return null;
        }
Exemple #11
0
 private void SubscribedItem_OnItemEvent(ItemEventMessage m)
 {
     this.peer.SendEvent(m.EventData, m.SendParameters);
 }
Exemple #12
0
 private void PublishUpdate(Item item, Vector position, bool remove, bool unreliable)
 {
     var updateEvent = GetUpdateEvent(item, position, remove);
     IEventData eventData = new EventData((byte)EventCode.RadarUpdate, updateEvent);
     var message = new ItemEventMessage(item, eventData, new SendParameters { Unreliable = unreliable, ChannelId = Settings.RadarEventChannel });
     this.channel.Publish(message);
 }
Exemple #13
0
 /// <summary>
 /// Publishes event ItemDestroyed in the Item.EventChannel.
 /// </summary>
 protected void OnDestroy()
 {
     var eventInstance = new ItemDestroyed { ItemId = this.Id };
     var eventData = new EventData((byte)EventCode.ItemDestroyed, eventInstance);
     var message = new ItemEventMessage(this, eventData, new SendParameters { ChannelId = Settings.ItemEventChannel });
     this.EventChannel.Publish(message);
 }
 /// <summary>
 /// Event relayed by subscribed region from region's items.
 /// </summary>
 private void Region_OnItemEvent(ItemEventMessage message)
 {
     ItemEventMessage.CounterEventReceive.Increment();
     this.peer.SendEvent(message.EventData, message.SendParameters);
 }
 /// <summary>
 /// Event relayed by subscribed region from region's items.
 /// </summary>
 private void Region_OnItemEvent(ItemEventMessage message)
 {
     ItemEventMessage.CounterEventReceive.Increment();
     this.peer.SendEvent(message.EventData, message.SendParameters);
 }