示例#1
0
文件: USender.cs 项目: mszubart/UCLA
        /// <summary>
        /// UCLA Sender constructor.
        /// Creates sender instance from specified config.
        /// </summary>
        /// <param name="config">Reference to configuration object.</param>
        /// <param name="autostart">Tells if connection will be started automatically. 
        /// Otherwise you will have to call Start method. Default value = false.</param>
        public USender(UConfig config, bool autostart = false)
        {
            this.endpoint = config.Endpoint;

            if (autostart) {
                this.Start();
            }
        }
示例#2
0
        /// <summary>
        /// Creates configuration object for receiver.
        /// </summary>
        /// <param name="inputName">Input name.</param>
        /// <returns>Configuration object.</returns>
        public UConfig GetReceiverConfig(string inputName)
        {
            if (this.inputConfig.GetValue(inputName) == null)
                throw new ULoaderException("There is no such input defined in config file. Input name: '" + inputName + "'");

            var configInterface = this.inputConfig.GetValue(inputName)["interface"];
            if (configInterface == null)
                throw new ULoaderException("Cannot read 'interface' vale from specified configuration.");

            var configPort = this.inputConfig.GetValue(inputName)["port"];
            if (configPort == null)
                throw new ULoaderException("Cannot read 'port' vale from specified configuration.");

            UConfig config = new UConfig((String) configInterface, (String) configPort);

            return config;
        }
示例#3
0
        /// <summary>
        /// Creates configuration object for sender.
        /// </summary>
        /// <param name="outputName">Output name.</param>
        /// <returns>Configuration object.</returns>
        public UConfig GetSenderConfig(string outputName)
        {
            if (this.outputConfig.GetValue(outputName) == null)
                throw new ULoaderException("There is no such output defined in config file. Output name: '" + outputName + "'");

            var configHost = this.outputConfig.GetValue(outputName)["host"];
            if (configHost == null)
                throw new ULoaderException("Cannot read 'host' vale from specified configuration.");

            var configPort = this.outputConfig.GetValue(outputName)["port"];
            if (configPort == null)
                throw new ULoaderException("Cannot read 'port' vale from specified configuration.");

            UConfig config = new UConfig((String) configHost, (String) configPort);
            return config;
        }