Ejemplo n.º 1
0
        /// <summary>
        /// Create new instance of UaPubSubConnection with PubSubConnectionDataType configuration data
        /// </summary>
        internal UaPubSubConnection(UaPubSubApplication parentUaPubSubApplication, PubSubConnectionDataType pubSubConnectionDataType)
        {
            // set the default message context that uses the GlobalContext
            MessageContext = new ServiceMessageContext
            {
                NamespaceUris = ServiceMessageContext.GlobalContext.NamespaceUris,
                ServerUris    = ServiceMessageContext.GlobalContext.ServerUris
            };

            if (parentUaPubSubApplication == null)
            {
                throw new ArgumentNullException(nameof(parentUaPubSubApplication));
            }

            m_uaPubSubApplication = parentUaPubSubApplication;
            m_uaPubSubApplication.UaPubSubConfigurator.WriterGroupAdded += UaPubSubConfigurator_WriterGroupAdded;
            m_pubSubConnectionDataType = pubSubConnectionDataType;

            m_publishers = new List <IUaPublisher>();

            if (string.IsNullOrEmpty(pubSubConnectionDataType.Name))
            {
                pubSubConnectionDataType.Name = "<connection>";
                Utils.Trace("UaPubSubConnection() received a PubSubConnectionDataType object without name. '<connection>' will be used");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create connections from PubSubConnectionDataType configuration objects.
 /// </summary>
 /// <param name="uaPubSubApplication"></param>
 /// <param name="pubSubConnectionDataType"></param>
 /// <returns></returns>
 public static UaPubSubConnection CreateConnection(UaPubSubApplication uaPubSubApplication, PubSubConnectionDataType pubSubConnectionDataType)
 {
     if (pubSubConnectionDataType.TransportProfileUri == Profiles.UadpTransport)
     {
         return(new UadpPubSubConnection(uaPubSubApplication, pubSubConnectionDataType));
     }
     throw new ArgumentException("Invalid TransportProfileUri.", "pubSubConnectionDataType");
 }
        /// <summary>
        /// Create new instance of UaPubSubConnection with PubSubConnectionDataType configuration data
        /// </summary>
        /// <param name="parentUaPubSubApplication"></param>
        /// <param name="pubSubConnectionDataType"></param>
        public UaPubSubConnection(UaPubSubApplication parentUaPubSubApplication, PubSubConnectionDataType pubSubConnectionDataType)
        {
            m_uaPubSubApplication = parentUaPubSubApplication;
            m_uaPubSubApplication.UaPubSubConfigurator.WriterGroupAdded += UaPubSubConfigurator_WriterGroupAdded;
            m_pubSubConnectionDataType = pubSubConnectionDataType;

            m_publishers = new List <IUaPublisher>();

            if (string.IsNullOrEmpty(pubSubConnectionDataType.Name))
            {
                pubSubConnectionDataType.Name = "<connection>";
            }
        }
        /// <summary>
        /// Creates a new <see cref="UaPubSubApplication"/> by loading the configuration parameters from the
        /// specified <see cref="PubSubConfigurationDataType"/> parameter.
        /// </summary>
        /// <param name="pubSubConfiguration">The configuration object.</param>
        /// <param name="dataStore"> The current implementation of <see cref="IUaPubSubDataStore"/> used by this instance of pub sub application</param>
        /// <returns>New instance of <see cref="UaPubSubApplication"/></returns>
        public static UaPubSubApplication Create(PubSubConfigurationDataType pubSubConfiguration = null, IUaPubSubDataStore dataStore = null)
        {
            // if no argument received, start with empty configuration
            if (pubSubConfiguration == null)
            {
                pubSubConfiguration = new PubSubConfigurationDataType();
            }

            UaPubSubApplication uaPubSubApplication = new UaPubSubApplication(dataStore);

            uaPubSubApplication.m_uaPubSubConfigurator.LoadConfiguration(pubSubConfiguration);
            return(uaPubSubApplication);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Create connections from PubSubConnectionDataType configuration objects.
 /// </summary>
 /// <param name="uaPubSubApplication">The parent <see cref="UaPubSubApplication"/></param>
 /// <param name="pubSubConnectionDataType">The configuration object for the new <see cref="UaPubSubConnection"/></param>
 /// <returns>The new instance of <see cref="UaPubSubConnection"/>.</returns>
 public static UaPubSubConnection CreateConnection(UaPubSubApplication uaPubSubApplication, PubSubConnectionDataType pubSubConnectionDataType)
 {
     if (pubSubConnectionDataType.TransportProfileUri == Profiles.PubSubUdpUadpTransport)
     {
         return(new UdpPubSubConnection(uaPubSubApplication, pubSubConnectionDataType));
     }
     else if (pubSubConnectionDataType.TransportProfileUri == Profiles.PubSubMqttUadpTransport)
     {
         return(new MqttPubSubConnection(uaPubSubApplication, pubSubConnectionDataType, MessageMapping.Uadp));
     }
     else if (pubSubConnectionDataType.TransportProfileUri == Profiles.PubSubMqttJsonTransport)
     {
         return(new MqttPubSubConnection(uaPubSubApplication, pubSubConnectionDataType, MessageMapping.Json));
     }
     throw new ArgumentException("Invalid TransportProfileUri.", nameof(pubSubConnectionDataType));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Create new instance of UaPubSubConnection with PubSubConnectionDataType configuration data
        /// </summary>
        public UaPubSubConnection(UaPubSubApplication parentUaPubSubApplication, PubSubConnectionDataType pubSubConnectionDataType)
        {
            if (parentUaPubSubApplication == null)
            {
                throw new ArgumentNullException(nameof(parentUaPubSubApplication));
            }

            m_uaPubSubApplication = parentUaPubSubApplication;
            m_uaPubSubApplication.UaPubSubConfigurator.WriterGroupAdded += UaPubSubConfigurator_WriterGroupAdded;
            m_pubSubConnectionDataType = pubSubConnectionDataType;

            m_publishers = new List<IUaPublisher>();

            if (string.IsNullOrEmpty(pubSubConnectionDataType.Name))
            {
                pubSubConnectionDataType.Name = "<connection>";
                Utils.Trace("UaPubSubConnection() received a PubSubConnectionDataType object without name. '<connection>' will be used");
            }
        }