Exemplo n.º 1
0
        /// <summary>
        /// returns a newly instantiated host with the given throttling.  The host is in the Uninitialized state.
        /// </summary>
        /// <param name="port"></param>
        /// <param name="logic"></param>
        /// <param name="maxConnections"></param>
        /// <returns></returns>
        public static IEndPointHost BuildThrottledHost(int port, IEndPointLogic logic, int maxConnections)
        {
            var builder       = EndPointHostBuilder.Instance.GetBuilder();
            var ep            = EndPointHelper.GetLocalEndPoint(port);
            var throttleLogic = ThrottleLogic(logic, maxConnections);
            var host          = builder.BuildEndPointHost(ep, throttleLogic);

            return(host);
        }
Exemplo n.º 2
0
        /// <summary>
        /// returns a newly instantiated host with the given throttling.  The host is in the Uninitialized state.
        /// </summary>
        /// <param name="wireBuilderId"></param>
        /// <param name="port"></param>
        /// <param name="logic"></param>
        /// <param name="maxConnections"></param>
        /// <returns></returns>
        public static IEndPointHost BuildThrottledHost(string wireBuilderId, int port, IEndPointLogic logic, int maxConnections)
        {
            var builder = EndPointHostBuilder.Instance.GetBuilder(wireBuilderId);
            var ep = EndPointHelper.GetLocalEndPoint(port);
            var throttleLogic = ThrottleLogic(logic, maxConnections);
            var host = builder.BuildEndPointHost(ep, throttleLogic);

            return host;
        }
Exemplo n.º 3
0
        /// <summary>
        /// builds a host on the Loopback address (with next avail port) that ONLY allows clients also
        /// coming from the Loopback.  This is great for local machine IPC
        /// </summary>
        /// <param name="logic"></param>
        /// <returns></returns>
        public IEndPointHost BuildNextAvailableLocalOnlyHost(IEndPointLogic logic)
        {
            //get the next available local ip 
            var ep = EndPointHelper.GetNextFreeLoopbackEndPoint();
            Condition.Requires(ep).IsNotNull();

            Func<System.Net.IPEndPoint, bool> validator = (x) =>
            {
                return x.Address.Equals(System.Net.IPAddress.Loopback);
            };

            return this.BuildEndPointHost(ep, logic, validator);
        }
Exemplo n.º 4
0
        /// <summary>
        /// builds a host on the Loopback address (with next avail port) that ONLY allows clients also
        /// coming from the Loopback.  This is great for local machine IPC
        /// </summary>
        /// <param name="logic"></param>
        /// <returns></returns>
        public IEndPointHost BuildNextAvailableLocalOnlyHost(IEndPointLogic logic)
        {
            //get the next available local ip
            var ep = EndPointHelper.GetNextFreeLoopbackEndPoint();

            Condition.Requires(ep).IsNotNull();

            Func <System.Net.IPEndPoint, bool> validator = (x) =>
            {
                return(x.Address.Equals(System.Net.IPAddress.Loopback));
            };

            return(this.BuildEndPointHost(ep, logic, validator));
        }
Exemplo n.º 5
0
 public IEndPointHost BuildEndPointHost(EndPoint endpoint, IEndPointLogic logic, Func<System.Net.IPEndPoint, bool> validateClientEndPointStrategy)
 {
     return new Host(endpoint, logic, validateClientEndPointStrategy);
 }
Exemplo n.º 6
0
 public IEndPointHost BuildEndPointHost(EndPoint endpoint, IEndPointLogic logic)
 {
     return new Host(endpoint, logic, null);
 }
Exemplo n.º 7
0
 /// <summary>
 /// adds throttling to the end point logic
 /// </summary>
 /// <param name="logic"></param>
 /// <param name="maxConnections"></param>
 /// <returns></returns>
 private static IThrottlingEndPointLogic ThrottleLogic(IEndPointLogic logic, int maxConnections)
 {
     return(new ThrottlingEndPointHostDecoration(logic, maxConnections));
 }
Exemplo n.º 8
0
 public IEndPointHost BuildEndPointHost(EndPoint endpoint, IEndPointLogic logic, Func <System.Net.IPEndPoint, bool> validateClientEndPointStrategy)
 {
     return(new Host(endpoint, logic, validateClientEndPointStrategy));
 }
Exemplo n.º 9
0
 public IEndPointHost BuildEndPointHost(EndPoint endpoint, IEndPointLogic logic)
 {
     return(new Host(endpoint, logic, null));
 }
Exemplo n.º 10
0
 /// <summary>
 /// adds throttling to the end point logic
 /// </summary>
 /// <param name="logic"></param>
 /// <param name="maxConnections"></param>
 /// <returns></returns>
 private static IThrottlingEndPointLogic ThrottleLogic(IEndPointLogic logic, int maxConnections)
 {
     return new ThrottlingEndPointHostDecoration(logic, maxConnections);
 }