Ejemplo n.º 1
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());
            }
        }
Ejemplo n.º 2
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.º 3
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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>Notifies the listener of a received interaction.</summary>
        /// <param name="msg"> the message of the received interaction</param>
        public void ReceiveInteraction(BaseInteractionMessage msg)
        {
#if POSIBLE_MEJORA
            if (bootstrapInteractionsDelegates[msg.FederationExecutionHandle].ContainsKey(msg.GetType()))
            {
                bootstrapInteractionsDelegates[msg.FederationExecutionHandle][msg.GetType()](msg);
            }
            else
            {
                bootstrapInteractionsDelegates[msg.FederationExecutionHandle][typeof(BaseInteractionMessage)](msg);
            }
#endif
            try
            {
                if (msg is HLAGenericInteractionMessage)
                {
                    foreach (IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IBootstrapObjectModelInteractionListener)
                        {
                            (il as IBootstrapObjectModelInteractionListener).OnReceiveHLAGenericInteraction(msg as HLAGenericInteractionMessage);
                        }
                        else
                        {
                            il.ReceiveInteraction(msg);
                        }
                    }
                }
                else if (msg is HLAinteractionFragmentMessage)
                {
                    foreach (IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IBootstrapObjectModelInteractionListener)
                        {
                            (il as IBootstrapObjectModelInteractionListener).OnReceiveHLAinteractionFragment(msg as HLAinteractionFragmentMessage);
                        }
                        else
                        {
                            il.ReceiveInteraction(msg);
                        }
                    }
                }
                else if (msg is HLAcontinueMessage)
                {
                    foreach (IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IBootstrapObjectModelInteractionListener)
                        {
                            (il as IBootstrapObjectModelInteractionListener).OnReceiveHLAcontinue(msg as HLAcontinueMessage);
                        }
                        else
                        {
                            il.ReceiveInteraction(msg);
                        }
                    }
                }
                else if (msg is PeerAdvertisementInteractionMessage)
                {
                    foreach (IInteractionListener il in manager.InteractionListeners)
                    {
                        if (il is IBootstrapObjectModelInteractionListener)
                        {
                            (il as IBootstrapObjectModelInteractionListener).OnReceivePeerAdvertisementInteraction(msg as PeerAdvertisementInteractionMessage);
                        }
                        else
                        {
                            il.ReceiveInteraction(msg);
                        }
                    }
                }
                else
                {
                    foreach (IInteractionListener il in manager.InteractionListeners)
                    {
                        il.ReceiveInteraction(msg);
                    }
                }
            }
            catch (System.IO.IOException ioe)
            {
                throw new FederateInternalError(ioe.ToString());
            }
        }