Exemplo n.º 1
0
        /// <summary>
        /// Calculates the number of required connections for routing and request messages.
        /// </summary>
        /// <param name="routingConfiguration">Contains the number of routing requests in parallel.</param>
        /// <param name="requestConfiguration">Contains the number of requests for P2P operations in parallel.</param>
        /// <param name="builder">The builder that tells us if we should TCP or UDP.</param>
        /// <returns>The future channel creator.</returns>
        public Task<ChannelCreator> CreateAsync(RoutingConfiguration routingConfiguration,
            IRequestConfiguration requestConfiguration, DefaultConnectionConfiguration builder)
        {
            if (routingConfiguration == null && requestConfiguration == null)
            {
                throw new ArgumentException("Both routing configuration and request configuration must be set.");
            }

            int nrConnectionsUdp = 0;
            int nrConnectionsTcp = 0;
            if (requestConfiguration != null)
            {
                if (builder.IsForceUdp)
                {
                    nrConnectionsUdp = requestConfiguration.Parallel;
                }
                else
                {
                    nrConnectionsTcp = requestConfiguration.Parallel;
                }
            }
            if (routingConfiguration != null)
            {
                if (!builder.IsForceTcp)
                {
                    nrConnectionsUdp = Math.Max(nrConnectionsUdp, routingConfiguration.Parallel);
                }
                else
                {
                    nrConnectionsTcp = Math.Max(nrConnectionsTcp, routingConfiguration.Parallel);
                }
            }

            return CreateAsync(nrConnectionsUdp, nrConnectionsTcp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the number of required connections for routing and request messages.
        /// </summary>
        /// <param name="routingConfiguration">Contains the number of routing requests in parallel.</param>
        /// <param name="requestConfiguration">Contains the number of requests for P2P operations in parallel.</param>
        /// <param name="builder">The builder that tells us if we should TCP or UDP.</param>
        /// <returns>The future channel creator.</returns>
        public Task <ChannelCreator> CreateAsync(RoutingConfiguration routingConfiguration,
                                                 IRequestConfiguration requestConfiguration, DefaultConnectionConfiguration builder)
        {
            if (routingConfiguration == null && requestConfiguration == null)
            {
                throw new ArgumentException("Both routing configuration and request configuration must be set.");
            }

            int nrConnectionsUdp = 0;
            int nrConnectionsTcp = 0;

            if (requestConfiguration != null)
            {
                if (builder.IsForceUdp)
                {
                    nrConnectionsUdp = requestConfiguration.Parallel;
                }
                else
                {
                    nrConnectionsTcp = requestConfiguration.Parallel;
                }
            }
            if (routingConfiguration != null)
            {
                if (!builder.IsForceTcp)
                {
                    nrConnectionsUdp = Math.Max(nrConnectionsUdp, routingConfiguration.Parallel);
                }
                else
                {
                    nrConnectionsTcp = Math.Max(nrConnectionsTcp, routingConfiguration.Parallel);
                }
            }

            return(CreateAsync(nrConnectionsUdp, nrConnectionsTcp));
        }