/// <summary>Notifies the listener of a received interaction.</summary>
 /// <param name="msg"> the message of the received interaction</param>
 public void ReceiveInteraction(BaseInteractionMessage msg)
 {
     try
     {
         /*
         if (msg is CommunicationMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is IHelloWorldObjectModelInteractionListener)
                     (il as IHelloWorldObjectModelInteractionListener).OnReceiveCommunication(msg as CommunicationMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else
         */
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 il.ReceiveInteraction(msg);
             }
     }
     catch (System.IO.IOException ioe)
     {
         throw new FederateInternalError(ioe.ToString());
     }
 }
 public override void ReceiveInteraction(BaseInteractionMessage msg)
 {
     try
     {
         if (msg is HLAregisterObjectInstanceMessage)
         {
             this.OnReceiveHLAregisterObjectInstance(msg as HLAregisterObjectInstanceMessage);
         }
         else if (msg is HLAregisterObjectInstanceWithTimeMessage)
         {
             this.OnReceiveHLAregisterObjectInstanceWithTime(msg as HLAregisterObjectInstanceWithTimeMessage);
         }
         else if (msg is HLAupdateAttributeValuesBestEffortWithTimeMessage)
         {
             this.OnReceiveHLAupdateAttributeValuesBestEffortWithTime(msg as HLAupdateAttributeValuesBestEffortWithTimeMessage);
         }
         else if (msg is HLAupdateAttributeValuesReliableWithTimeMessage)
         {
             this.OnReceiveHLAupdateAttributeValuesReliableWithTime(msg as HLAupdateAttributeValuesReliableWithTimeMessage);
         }
         else if (msg is HLAupdateAttributeValuesBestEffortMessage)
         {
             this.OnReceiveHLAupdateAttributeValuesBestEffort(msg as HLAupdateAttributeValuesBestEffortMessage);
         }
         else if (msg is HLAupdateAttributeValuesReliableMessage)
         {
             this.OnReceiveHLAupdateAttributeValuesReliable(msg as HLAupdateAttributeValuesReliableMessage);
         }
     }
     catch (System.IO.IOException ioe)
     {
         throw new FederateInternalError(ioe.ToString());
     }
 }
Ejemplo n.º 3
0
        ///<summary>
        /// Reads and returns a BaseIteractionMessage from the specified stream.
        ///</summary>
        ///<param name="reader"> the input stream to read from</param>
        ///<returns> the decoded parameterValue</returns>
        ///<exception cref="System.IO.IOException"> if an error occurs</exception>
        public override object Deserialize(HlaEncodingReader reader, ref object msg)
        {
            if (msg == null)
            {
                msg = new BaseInteractionMessage();
            }
            BaseInteractionMessage decodedValue = msg as BaseInteractionMessage;

            decodedValue.FederateHandle            = reader.ReadHLAinteger64BE();
            decodedValue.InteractionIndex          = reader.ReadHLAinteger64BE();
            decodedValue.FederationExecutionHandle = reader.ReadHLAinteger64BE();
            decodedValue.UserSuppliedTag           = reader.ReadHLAopaqueData();
            decodedValue.InteractionClassHandle    = reader.ReadHLAinteger64BE();

            IHlaEncodingSerializer serializer = serializerManager.GetSerializer(decodedValue.InteractionClassHandle);

            if (serializer != null && !this.Equals(serializer))
            {
                object decodedValueTmp = decodedValue;
                return(serializer.Deserialize(reader, ref decodedValueTmp));
            }
            else
            {
                return(decodedValue);
            }
        }
 public void ReceiveInteraction(BaseInteractionMessage msg)
 {
     /*
     if (log.IsDebugEnabled)
         log.Debug("Received BaseInteractionMessage =  " + msg.ToString());
     */
 }
Ejemplo n.º 5
0
 public void CopyTo(BaseInteractionMessage obj)
 {
     this.FederationExecutionHandle = obj.FederationExecutionHandle;
     this.UserSuppliedTag           = obj.UserSuppliedTag;
     this.InteractionClassHandle    = obj.InteractionClassHandle;
     this.FederateHandle            = obj.FederateHandle;
     this.InteractionIndex          = obj.InteractionIndex;
 }
 /// <summary>Notifies the listener of a received interaction.</summary>
 /// <param name="msg"> the message of the received interaction</param>
 public void ReceiveInteraction(BaseInteractionMessage msg)
 {
     try
     {
         foreach (IInteractionListener il in manager.InteractionListeners)
         {
             il.ReceiveInteraction(msg);
         }
     }
     catch (System.IO.IOException ioe)
     {
         throw new FederateInternalError(ioe.ToString());
     }
 }
 /// <summary>Notifies the listener of a received interaction.</summary>
 /// <param name="msg"> the message of the received interaction</param>
 public void ReceiveInteraction(BaseInteractionMessage msg)
 {
     try
     {
         lock (manager.InteractionListeners)
         {
             if (msg is HLAcreateFederationExecutionMessage)
             {
                 foreach (IInteractionListener il in manager.InteractionListeners)
                 {
                     if (il is IMetaFederationObjectModelInteractionListener)
                         (il as IMetaFederationObjectModelInteractionListener).OnReceiveHLAcreateFederationExecution(msg as HLAcreateFederationExecutionMessage);
                     else
                         il.ReceiveInteraction(msg);
                 }
             }
             else if (msg is HLAdestroyFederationExecutionMessage)
             {
                 foreach (IInteractionListener il in manager.InteractionListeners)
                 {
                     if (il is IMetaFederationObjectModelInteractionListener)
                         (il as IMetaFederationObjectModelInteractionListener).OnReceiveHLAdestroyFederationExecution(msg as HLAdestroyFederationExecutionMessage);
                     else
                         il.ReceiveInteraction(msg);
                 }
             }
             else if (msg is HLAjoinFederationExecutionMessage)
             {
                 foreach (IInteractionListener il in manager.InteractionListeners)
                 {
                     if (il is IMetaFederationObjectModelInteractionListener)
                         (il as IMetaFederationObjectModelInteractionListener).OnReceiveHLAjoinFederationExecution(msg as HLAjoinFederationExecutionMessage);
                     else
                         il.ReceiveInteraction(msg);
                 }
             }
             else
                 foreach (IInteractionListener il in manager.InteractionListeners)
                 {
                     il.ReceiveInteraction(msg);
                 }
         }
     }
     catch(System.IO.IOException ioe)
     {
         throw new FederateInternalError(ioe.ToString());
     }
 }
Ejemplo n.º 8
0
        ///<summary>
        /// Writes this HLAparameterHandleValuePair to the specified stream.
        ///</summary>
        ///<param name="writer"> the output stream to write to</param>
        ///<param name="obj"> the object to serialize</param>
        ///<exception cref="IOException"> if an error occurs</exception>
        public override void Serialize(HlaEncodingWriter writer, object obj)
        {
            BaseInteractionMessage msg = obj as BaseInteractionMessage;

            writer.WriteHLAinteger64BE(msg.FederateHandle);
            writer.WriteHLAinteger64BE(msg.InteractionIndex);
            writer.WriteHLAinteger64BE(msg.FederationExecutionHandle);
            writer.WriteHLAopaqueData(msg.UserSuppliedTag);
            writer.WriteHLAinteger64BE(msg.InteractionClassHandle);
            IHlaEncodingSerializer serializer = serializerManager.GetSerializer(msg.InteractionClassHandle);

            if (serializer != null && !this.Equals(serializer))
            {
                serializer.Serialize(writer, obj);
            }
        }
Ejemplo n.º 9
0
        ///<summary> Reads this HLAinteractionRootMessage from the specified stream.</summary>
        ///<param name="reader"> the input stream to read from</param>
        ///<returns> the object</returns>
        ///<exception cref="IOException"> if an error occurs</exception>
        public override object Deserialize(HlaEncodingReader reader, ref object msg)
        {
            HLAinteractionRootMessage decodedValue;

            if (!(msg is HLAinteractionRootMessage))
            {
                decodedValue = new HLAinteractionRootMessage();
                BaseInteractionMessage baseMsg = msg as BaseInteractionMessage;
                decodedValue.InteractionClassHandle    = baseMsg.InteractionClassHandle;
                decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle;
                decodedValue.UserSuppliedTag           = baseMsg.UserSuppliedTag;
            }
            else
            {
                decodedValue = msg as HLAinteractionRootMessage;
            }
            object tmp = decodedValue;

            decodedValue = base.Deserialize(reader, ref tmp) as HLAinteractionRootMessage;

            return(decodedValue);
        }
 public abstract void ReceiveInteraction(BaseInteractionMessage msg);
 public void OnReceiveHLAupdateAttributeValuesReliableWithTimeBase(BaseInteractionMessage msg)
 {
     OnReceiveHLAupdateAttributeValuesReliableWithTime(msg as HLAupdateAttributeValuesReliableWithTimeMessage);
 }
 public void OnReceiveHLAupdateAttributeValuesBestEffortBase(BaseInteractionMessage msg)
 {
     OnReceiveHLAupdateAttributeValuesBestEffort(msg as HLAupdateAttributeValuesBestEffortMessage);
 }
 public void OnReceiveHLArequestHandlesBase(BaseInteractionMessage msg)
 {
     OnReceiveHLArequestHandles(msg as HLArequestHandlesMessage);
 }
 public void OnReceiveHLArequestAttributeValueUpdateBase(BaseInteractionMessage msg)
 {
     OnReceiveHLArequestAttributeValueUpdate(msg as HLArequestAttributeValueUpdateMessage);
 }
 public void OnReceiveHLAregisterObjectInstanceWithTimeBase(BaseInteractionMessage msg)
 {
     OnReceiveHLAregisterObjectInstanceWithTime(msg as HLAregisterObjectInstanceWithTimeMessage);
 }
Ejemplo n.º 16
0
        private void SendBestEffortInteraction(IMessageChannel messageChannel, BaseInteractionMessage msg)
        {
            /*
            if (log.IsInfoEnabled)
                log.Info("On " + System.Reflection.MethodBase.GetCurrentMethod());
            */
            try
            {
                System.IO.MemoryStream bufferStream = new System.IO.MemoryStream();
                serializer.Serialize(bufferStream, msg);

                byte[] buffer = bufferStream.ToArray();

                SendBestEffortInteraction(messageChannel, buffer);
            }
            catch (System.Exception e)
            {
                throw new RTIinternalError(e.Message);
            }
        }
Ejemplo n.º 17
0
 public void CopyTo(BaseInteractionMessage obj)
 {
     this.FederationExecutionHandle = obj.FederationExecutionHandle;
     this.UserSuppliedTag = obj.UserSuppliedTag;
     this.InteractionClassHandle = obj.InteractionClassHandle;
     this.FederateHandle = obj.FederateHandle;
     this.InteractionIndex = obj.InteractionIndex;
 }
Ejemplo n.º 18
0
        /// <summary> 
        /// Sends an interaction.
        /// </summary>
        /// <param name="msg">the message or interaction to send
        /// </param>
        public virtual void SendInteraction(TransportationType transport, BaseInteractionMessage msg)
        {
            if (!channel2TransportationMap.ContainsKey(transport))
                throw new Exception("Transport unknown");

            foreach (KeyValuePair<TransportationType, ChannelType> keyValue in channel2TransportationMap)
            {
                if (keyValue.Key.Equals(transport))
                {
                    try
                    {
                        ChannelType channelType = keyValue.Value;
                        if (channelType.Equals(ChannelType.TCP))
                        {
                            SendRealiableInteraction(channelType, msg);
                        }
                        else
                        {
                            SendBestEffortInteraction(channelType, msg);
                        }
                    }
                    catch (Exception e)
                    {
                        //TODO. What should I do when the channel is remotly closed and lost??.
                        //TODO.
                        if (log.IsWarnEnabled)
                            log.Warn("Error sending interaction: " + e.Message);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary> 
        /// Sends an interaction with reliable (TCP) transportation.
        /// </summary>
        /// <param name="msg">the interaction message
        /// </param>
        /// <exception cref="InteractionClassNotPublished"> if the interaction class is not published
        /// </exception>
        /// <exception cref="InteractionClassNotDefined"> if the interaction class is undefined
        /// </exception>
        /// <exception cref="InteractionParameterNotDefined"> if one of the parameters is undefined
        /// </exception>
        /// <exception cref="FederateNotExecutionMember"> if the federate is not a member of an execution
        /// </exception>
        /// <exception cref="SaveInProgress"> if a save operation is in progress
        /// </exception>
        /// <exception cref="RestoreInProgress"> if a restore operation is in progress
        /// </exception>
        /// <exception cref="RTIinternalError"> if an internal error occurred in the
        /// run-time infrastructure
        /// </exception>
        public virtual void SendRealiableInteraction(ChannelType channelType, BaseInteractionMessage msg)
        {
            /*
            if (log.IsInfoEnabled)
                log.Info("On " + System.Reflection.MethodBase.GetCurrentMethod());
            */

            IList<IMessageChannel> list = channelManager.ChannelsList(channelType);
            if (list != null)
                foreach (StreamMessageChannel messageChannel in list)
                {
                    try
                    {
                        SendRealiableInteraction(messageChannel, msg);
                    }
                    catch (Exception e)
                    {
                        //TODO. What should I do when the channel is remotly closed and lost??.
                        //TODO.
                        if (log.IsWarnEnabled)
                            log.Warn("Error sending interaction: " + e.Message);
                    }
                }
        }
        /// <summary>Notifies the listener of a received interaction.</summary>
        /// <param name="msg"> the message of the received interaction</param>
        public void ReceiveInteraction(BaseInteractionMessage msg)
        {
            try
            {
                if(msg is HLApublishObjectClassAttributesMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLApublishObjectClassAttributes(msg as HLApublishObjectClassAttributesMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                
                else if(msg is HLApublishInteractionClassMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLApublishInteractionClass(msg as HLApublishInteractionClassMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                
                else if(msg is HLAsubscribeObjectClassAttributesMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAsubscribeObjectClassAttributes(msg as HLAsubscribeObjectClassAttributesMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                
                else if(msg is HLAsubscribeInteractionClassMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAsubscribeInteractionClass(msg as HLAsubscribeInteractionClassMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }

                /*
                else if(msg is HLAunpublishObjectClassAttributesMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAunpublishObjectClassAttributes(msg as HLAunpublishObjectClassAttributesMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAunpublishInteractionClassMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAunpublishInteractionClass(msg as HLAunpublishInteractionClassMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAunsubscribeObjectClassAttributesMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAunsubscribeObjectClassAttributes(msg as HLAunsubscribeObjectClassAttributesMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAunsubscribeInteractionClassMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAunsubscribeInteractionClass(msg as HLAunsubscribeInteractionClassMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                */
                else {

                    foreach (IInteractionListener il in manager.InteractionListeners)
                    {
                        il.ReceiveInteraction(msg);
                    }
                }

                # if SIN_INTEGRAR_EN_EL_SISTEMA
                /*
                if(msg is HLAsetTimingMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAsetTiming(msg as HLAsetTimingMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAmodifyAttributeStateMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAmodifyAttributeState(msg as HLAmodifyAttributeStateMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAsetServiceReportingMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAsetServiceReporting(msg as HLAsetServiceReportingMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAsetExceptionReportingMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAsetExceptionReporting(msg as HLAsetExceptionReportingMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestPublicationsMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestPublications(msg as HLArequestPublicationsMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestSubscriptionsMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestSubscriptions(msg as HLArequestSubscriptionsMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestObjectInstancesThatCanBeDeletedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestObjectInstancesThatCanBeDeleted(msg as HLArequestObjectInstancesThatCanBeDeletedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestObjectInstancesUpdatedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestObjectInstancesUpdated(msg as HLArequestObjectInstancesUpdatedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestObjectInstancesReflectedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestObjectInstancesReflected(msg as HLArequestObjectInstancesReflectedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestUpdatesSentMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestUpdatesSent(msg as HLArequestUpdatesSentMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestInteractionsSentMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestInteractionsSent(msg as HLArequestInteractionsSentMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestReflectionsReceivedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestReflectionsReceived(msg as HLArequestReflectionsReceivedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestInteractionsReceivedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestInteractionsReceived(msg as HLArequestInteractionsReceivedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestObjectInstanceInformationMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestObjectInstanceInformation(msg as HLArequestObjectInstanceInformationMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestSynchronizationPointsMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestSynchronizationPoints(msg as HLArequestSynchronizationPointsMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLArequestSynchronizationPointStatusMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLArequestSynchronizationPointStatus(msg as HLArequestSynchronizationPointStatusMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportObjectClassPublicationMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportObjectClassPublication(msg as HLAreportObjectClassPublicationMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportObjectClassSubscriptionMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportObjectClassSubscription(msg as HLAreportObjectClassSubscriptionMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportInteractionPublicationMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportInteractionPublication(msg as HLAreportInteractionPublicationMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportInteractionSubscriptionMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportInteractionSubscription(msg as HLAreportInteractionSubscriptionMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportObjectInstancesThatCanBeDeletedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportObjectInstancesThatCanBeDeleted(msg as HLAreportObjectInstancesThatCanBeDeletedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportObjectInstancesUpdatedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportObjectInstancesUpdated(msg as HLAreportObjectInstancesUpdatedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportObjectInstancesReflectedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportObjectInstancesReflected(msg as HLAreportObjectInstancesReflectedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportUpdatesSentMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportUpdatesSent(msg as HLAreportUpdatesSentMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportReflectionsReceivedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportReflectionsReceived(msg as HLAreportReflectionsReceivedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportInteractionsSentMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportInteractionsSent(msg as HLAreportInteractionsSentMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportInteractionsReceivedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportInteractionsReceived(msg as HLAreportInteractionsReceivedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportObjectInstanceInformationMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportObjectInstanceInformation(msg as HLAreportObjectInstanceInformationMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportExceptionMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportException(msg as HLAreportExceptionMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportServiceInvocationMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportServiceInvocation(msg as HLAreportServiceInvocationMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportMOMexceptionMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportMOMexception(msg as HLAreportMOMexceptionMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportSynchronizationPointsMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportSynchronizationPoints(msg as HLAreportSynchronizationPointsMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAreportSynchronizationPointStatusMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAreportSynchronizationPointStatus(msg as HLAreportSynchronizationPointStatusMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAresignFederationExecutionMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAresignFederationExecution(msg as HLAresignFederationExecutionMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAsynchronizationPointAchievedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAsynchronizationPointAchieved(msg as HLAsynchronizationPointAchievedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAfederateSaveBegunMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAfederateSaveBegun(msg as HLAfederateSaveBegunMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAfederateSaveCompleteMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAfederateSaveComplete(msg as HLAfederateSaveCompleteMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAfederateRestoreCompleteMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAfederateRestoreComplete(msg as HLAfederateRestoreCompleteMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAdeleteObjectInstanceMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAdeleteObjectInstance(msg as HLAdeleteObjectInstanceMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAlocalDeleteObjectInstanceMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAlocalDeleteObjectInstance(msg as HLAlocalDeleteObjectInstanceMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAchangeAttributeTransportationTypeMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAchangeAttributeTransportationType(msg as HLAchangeAttributeTransportationTypeMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAchangeInteractionTransportationTypeMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAchangeInteractionTransportationType(msg as HLAchangeInteractionTransportationTypeMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAunconditionalAttributeOwnershipDivestitureMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAunconditionalAttributeOwnershipDivestiture(msg as HLAunconditionalAttributeOwnershipDivestitureMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAenableTimeRegulationMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAenableTimeRegulation(msg as HLAenableTimeRegulationMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAdisableTimeRegulationMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAdisableTimeRegulation(msg as HLAdisableTimeRegulationMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAenableTimeConstrainedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAenableTimeConstrained(msg as HLAenableTimeConstrainedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAdisableTimeConstrainedMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAdisableTimeConstrained(msg as HLAdisableTimeConstrainedMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAtimeAdvanceRequestMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAtimeAdvanceRequest(msg as HLAtimeAdvanceRequestMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAtimeAdvanceRequestAvailableMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAtimeAdvanceRequestAvailable(msg as HLAtimeAdvanceRequestAvailableMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAnextMessageRequestMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAnextMessageRequest(msg as HLAnextMessageRequestMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAnextMessageRequestAvailableMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAnextMessageRequestAvailable(msg as HLAnextMessageRequestAvailableMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAflushQueueRequestMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAflushQueueRequest(msg as HLAflushQueueRequestMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAenableAsynchronousDeliveryMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAenableAsynchronousDelivery(msg as HLAenableAsynchronousDeliveryMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAdisableAsynchronousDeliveryMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAdisableAsynchronousDelivery(msg as HLAdisableAsynchronousDeliveryMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAmodifyLookaheadMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAmodifyLookahead(msg as HLAmodifyLookaheadMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAchangeAttributeOrderTypeMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAchangeAttributeOrderType(msg as HLAchangeAttributeOrderTypeMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAchangeInteractionOrderTypeMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAchangeInteractionOrderType(msg as HLAchangeInteractionOrderTypeMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }
                else if(msg is HLAsetSwitchesMessage)
                {
                    foreach(IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IManagementObjectModelInteractionListener)
                            (il as IManagementObjectModelInteractionListener).OnReceiveHLAsetSwitches(msg as HLAsetSwitchesMessage);
                        else
                            il.ReceiveInteraction(msg);
                    }
                }

                #endif
            }
            catch(System.IO.IOException ioe)
            {
                throw new FederateInternalError(ioe.ToString());
            }

        }
 /// <summary>Notifies the listener of a received interaction.</summary>
 /// <param name="msg"> the message of the received interaction</param>
 public void ReceiveInteraction(BaseInteractionMessage msg)
 {
     try
     {
         if(msg is BoxInHouseMessage)
         {
             foreach(IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ITimeManagementObjectModelInteractionListener)
                     (il as ITimeManagementObjectModelInteractionListener).OnReceiveBoxInHouse(msg as BoxInHouseMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 il.ReceiveInteraction(msg);
             }
     }
     catch(System.IO.IOException ioe)
     {
         throw new FederateInternalError(ioe.ToString());
     }
 }
Ejemplo n.º 22
0
        /// <summary> 
        /// Sends an interaction with best-effort (UDP) transportation.
        /// </summary>
        /// <param name="msg">the interaction message
        /// </param>
        /// <exception cref="InteractionClassNotPublished"> if the interaction class is not published
        /// </exception>
        /// <exception cref="InteractionClassNotDefined"> if the interaction class is undefined
        /// </exception>
        /// <exception cref="InteractionParameterNotDefined"> if one of the parameters is undefined
        /// </exception>
        /// <exception cref="FederateNotExecutionMember"> if the federate is not a member of an execution
        /// </exception>
        /// <exception cref="SaveInProgress"> if a save operation is in progress
        /// </exception>
        /// <exception cref="RestoreInProgress"> if a restore operation is in progress
        /// </exception>
        /// <exception cref="RTIinternalError"> if an internal error occurred in the
        /// run-time infrastructure
        /// </exception>
        public virtual void SendBestEffortInteraction(ChannelType channelType, BaseInteractionMessage msg)
        {
            /*
            if (log.IsInfoEnabled)
                log.Info("On " + System.Reflection.MethodBase.GetCurrentMethod());
            */

            try
            {
                System.IO.MemoryStream bufferStream = new System.IO.MemoryStream();
                serializer.Serialize(bufferStream, msg);

                byte[] buffer = bufferStream.ToArray();

                IList<IMessageChannel> list = channelManager.ChannelsList(channelType);
                if (list != null)
                    foreach (IMessageChannel messageChannel in list)
                    {
                        SendBestEffortInteraction(messageChannel, buffer);
                    }
            }
            catch (System.Exception e)
            {
                throw new RTIinternalError(e.Message);
            }
        }
 /// <summary>Notifies the listener of a received interaction.</summary>
 /// <param name="msg"> the message of the received interaction</param>
 public void ReceiveInteraction(BaseInteractionMessage msg)
 {
     try
     {
         if (msg is HLArequestHandlesMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLArequestHandles(msg as HLArequestHandlesMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLAreportHandlesMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLAreportHandles(msg as HLAreportHandlesMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLAregisterObjectInstanceMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLAregisterObjectInstance(msg as HLAregisterObjectInstanceMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLAregisterObjectInstanceWithTimeMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLAregisterObjectInstanceWithTime(msg as HLAregisterObjectInstanceWithTimeMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLArequestAttributeValueUpdateMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLArequestAttributeValueUpdate(msg as HLArequestAttributeValueUpdateMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLAupdateAttributeValuesBestEffortWithTimeMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLAupdateAttributeValuesBestEffortWithTime(msg as HLAupdateAttributeValuesBestEffortWithTimeMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLAupdateAttributeValuesReliableWithTimeMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLAupdateAttributeValuesReliableWithTime(msg as HLAupdateAttributeValuesReliableWithTimeMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLAupdateAttributeValuesBestEffortMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLAupdateAttributeValuesBestEffort(msg as HLAupdateAttributeValuesBestEffortMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else if (msg is HLAupdateAttributeValuesReliableMessage)
         {
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 if (il is ILowLevelManagementObjectModelInteractionListener)
                     (il as ILowLevelManagementObjectModelInteractionListener).OnReceiveHLAupdateAttributeValuesReliable(msg as HLAupdateAttributeValuesReliableMessage);
                 else
                     il.ReceiveInteraction(msg);
             }
         }
         else
             foreach (IInteractionListener il in manager.InteractionListeners)
             {
                 il.ReceiveInteraction(msg);
             }
     }
     catch (System.IO.IOException ioe)
     {
         throw new FederateInternalError(ioe.ToString());
     }
 }
Ejemplo n.º 24
0
 public virtual void SendRealiableInteraction(StreamMessageChannel messageChannel, BaseInteractionMessage msg)
 {
     try
     {
         lock (messageChannel.SyncObject)
         {
             /*
             if (log.IsDebugEnabled)
                 log.Debug("Sending Interaction: " + msg);
             */
             serializer.Serialize(messageChannel.OutputStream, msg);
         }
     }
     catch (System.Exception e)
     {
         throw new RTIinternalError(e.Message);
     }
 }
Ejemplo n.º 25
0
        ///<summary>
        /// Reads and returns a BaseIteractionMessage from the specified stream.
        ///</summary>
        ///<param name="reader"> the input stream to read from</param>
        ///<returns> the decoded parameterValue</returns>
        ///<exception cref="System.IO.IOException"> if an error occurs</exception>
        public override object Deserialize(HlaEncodingReader reader, ref object msg)
        {
            if (msg == null)
            {
                msg = new BaseInteractionMessage();
            }
            BaseInteractionMessage decodedValue = msg as BaseInteractionMessage;
            decodedValue.FederateHandle = reader.ReadHLAinteger64BE();
            decodedValue.InteractionIndex = reader.ReadHLAinteger64BE();
            decodedValue.FederationExecutionHandle = reader.ReadHLAinteger64BE();
            decodedValue.UserSuppliedTag = reader.ReadHLAopaqueData();
            decodedValue.InteractionClassHandle = reader.ReadHLAinteger64BE();

            IHlaEncodingSerializer serializer = serializerManager.GetSerializer(decodedValue.InteractionClassHandle);

            if (serializer != null && !this.Equals(serializer))
            {
                object decodedValueTmp = decodedValue;
                return serializer.Deserialize(reader, ref decodedValueTmp);
            }
            else
                return decodedValue;
        }
Ejemplo n.º 26
0
        /// <summary> 
        /// Sends an interaction.
        /// </summary>
        /// <param name="decodedValue">the message or interaction to send
        /// </param>
        public virtual void SendInteraction(BaseInteractionMessage msg)
        {
            TransportationType transport = interactionChannelMap[msg.GetType()];

            // If transport is null, then we send it directly to
            // our listeners
            if (transport == null)
            {
                ReceiveInteraction(msg);
            }
            else
            {
                //msg.InteractionClassHandle = ((XRTIInteractionClassHandle)interactionClassDescriptorMap[msg.GetType()].Handle).Identifier;
                msg.InteractionClassHandle = SerializerManager.GetHandle(msg.GetType());

                SendInteraction(transport, msg);
            }
        }
 public void OnReceiveHLAsubscribeInteractionClassBase(BaseInteractionMessage msg)
 {
     OnReceiveHLAsubscribeInteractionClass(msg as HLAsubscribeInteractionClassMessage);
 }
Ejemplo n.º 28
0
 public void DispatchInteraction(BaseInteractionMessage msg)
 {
     if (interactionsDelegates.ContainsKey(msg.FederationExecutionHandle))
     {
         if (interactionsDelegates[msg.FederationExecutionHandle].ContainsKey(msg.GetType()))
             interactionsDelegates[msg.FederationExecutionHandle][msg.GetType()](msg);
         else
             interactionsDelegates[msg.FederationExecutionHandle][typeof(BaseInteractionMessage)](msg);
     }
 }
Ejemplo n.º 29
0
        /// <summary>Notifies the federate of a received interaction.</summary>
        /// <param name="decodedValue"> the message of the received interaction</param>
        public void ReceiveInteraction(BaseInteractionMessage msg)
        {
            if (log.IsDebugEnabled)
                log.Debug("Read msg: " + msg);

            try
            {
                if (interactionDelegates.ContainsKey(msg.GetType()))
                {
                    interactionDelegates[msg.GetType()](msg);
                }
                //else
                //{
                    lock (interactionListeners)
                    {
                        foreach (IInteractionListener il in interactionListeners)
                        {
                            (il as IInteractionListener).ReceiveInteraction(msg);
                        }
                    }
                //}
            }
            catch (IOException ioe)
            {
                throw new FederateInternalError(ioe.ToString());
            }
        }
 public void OnReceiveHLAsubscribeObjectClassAttributesBase(BaseInteractionMessage msg)
 {
     OnReceiveHLAsubscribeObjectClassAttributes(msg as HLAsubscribeObjectClassAttributesMessage);
 }