コード例 #1
0
ファイル: BaseProtocol.cs プロジェクト: agustinsantos/Sxta
        /// <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);
                        }
                    }
                }
            }
        }