public TcpClientTransport( EndPoint remoteEndPoint, RpcTransportProtocol protocol, ClientEventLoop eventLoop, RpcClientOptions options )
            : base(remoteEndPoint, protocol, eventLoop, options)
        {
            if ( protocol.ProtocolType != ProtocolType.Tcp )
            {
                throw new ArgumentException( "socket must be connected TCP socket.", "protocol" );
            }

            Contract.EndContractBlock();
        }
 public override ResponseMessageSerializer Create( RpcTransportProtocol protocol, RpcClientOptions options )
 {
     return
         new ResponseMessageSerializer(
             null,
             null,
             null,
             null,
             options == null ? _defaultResponseQuota : options.MaximumRequestQuota ?? _defaultResponseQuota
         );
 }
示例#3
0
        protected ClientTransport( RpcTransportProtocol protocol, ClientEventLoop eventLoop, RpcClientOptions options )
        {
            if ( eventLoop == null )
            {
                throw new ArgumentNullException( "eventLoop" );
            }

            Contract.EndContractBlock();

            this._eventLoop = eventLoop;
            this._requestSerializer = ClientServices.RequestSerializerFactory.Create( protocol, options );
            this._responseSerializer = ClientServices.ResponseDeserializerFactory.Create( protocol, options );
            this._drainTimeout = options == null ? TimeSpan.FromSeconds( 3 ) : options.DrainTimeout ?? TimeSpan.FromSeconds( 3 );
            this._options = options ?? new RpcClientOptions();
            this._options.Freeze();
        }
示例#4
0
        protected ServerEventLoop( Func<ServerSessionContext, RpcServerSession> sessionFactory, RpcTransportProtocol protocol, RpcServerOptions options, EventHandler<RpcTransportErrorEventArgs> errorHandler )
            : base(errorHandler)
        {
            if ( sessionFactory == null )
            {
                throw new ArgumentNullException( "sessionFactory" );
            }

            Contract.EndContractBlock();

            this._sessionFactory = sessionFactory;
            this._options = options;
            this._exeuctingWorkerThreadTable = new ConcurrentDictionary<int, WorkerThreadInfo>();
            this._sessionPool = new ConcurrentDictionary<EndPoint, RpcServerSession>();
            this._timeoutWatchDog = new Timer( this.CheckTimeout, null, ( long )this.TimeoutWatchPeriod.TotalMilliseconds, Timeout.Infinite );
        }
        protected ConnectionOrientedClientTransport( EndPoint remoteEndPoint, RpcTransportProtocol protocol, ClientEventLoop eventLoop, RpcClientOptions options )
            : base(protocol, eventLoop, options)
        {
            if ( remoteEndPoint == null )
            {
                throw new ArgumentNullException( "remoteEndPoint" );
            }

            this._connectionPool =
                new ConnectionPool(
                    remoteEndPoint,
                    protocol,
                    eventLoop,
                    options == null ? _defaultMinimumConnectionCount : ( options.MinimumConnectionCount ?? _defaultMinimumConnectionCount ),
                    options == null ? _defaultMaximumConnectionCount : ( options.MaximumConnectionCount ?? _defaultMaximumConnectionCount )
                );
            this._connectTimeout =
                options == null
                ? _defaultConnectTimeout
                : ( options.ConnectTimeout ?? _defaultConnectTimeout );
        }
示例#6
0
		public ConnectionPool( EndPoint destination, RpcTransportProtocol protocol, ClientEventLoop eventLoop, int minimumCount, int maximumCount )
		{
			if ( destination == null )
			{
				throw new ArgumentNullException( "destination" );
			}

			if ( eventLoop == null )
			{
				throw new ArgumentNullException( "eventLoop" );
			}

			if ( minimumCount < 0 )
			{
				throw new ArgumentOutOfRangeException( "minimumCount", "'minumumCount' cannot be negative." );
			}

			if ( maximumCount < 1 )
			{
				throw new ArgumentOutOfRangeException( "maximumCount", "'maximumCount' must be positive." );
			}

			if ( maximumCount < minimumCount )
			{
				throw new ArgumentException( "'maximumCount' cannot be lessor than 'minimumCount'.", "maximumCount" );
			}

			Contract.EndContractBlock();

			this._allocationLock = new object();
			this._cancellationTokenSource = new CancellationTokenSource();
			this._destination = destination;
			this._protocol = protocol;
			this._eventLoop = eventLoop;
			this._minimum = minimumCount;
			this._maximum = maximumCount;
			this._availableSockets = new BlockingCollection<RpcSocketAsyncEventArgs>( new ConcurrentQueue<RpcSocketAsyncEventArgs>(), maximumCount );
			this.AllocateMore();
		}
 /// <summary>
 ///		Create <see cref="RequestMessageSerializer"/> for specified protocol and configuration.
 /// </summary>
 /// <param name="protocol">Target protocol.</param>
 /// <param name="options">Option settings. This parameter can be null.</param>
 /// <returns><see cref="RequestMessageSerializer"/> for specified protocol and configuration.</returns>
 public abstract ResponseMessageSerializer Create( RpcTransportProtocol protocol, RpcClientOptions options );
 public IOCompletionPortServerEventLoop( Func<ServerSessionContext, RpcServerSession> sessionFactory, RpcTransportProtocol protocol, RpcServerOptions options, EventHandler<RpcTransportErrorEventArgs> errorHandler )
     : base(sessionFactory, protocol, options, errorHandler)
 {
 }