public TcpServerTransport(
			ServerEventLoop eventLoop,
			RpcServerOptions options,
			RequestMessageSerializer requestMessageSerializer,
			ResponseMessageSerializer responseMessageSerializer
		)
        {
            if ( eventLoop == null )
            {
                throw new ArgumentNullException( "eventLoop" );
            }

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

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

            Contract.EndContractBlock();

            this._eventLoop = eventLoop;
            this._options = options;
            this._requestSerializer = requestMessageSerializer;
            this._responseSerializer = responseMessageSerializer;
        }
Esempio n. 2
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();
        }
        public static ResponseMessage DeserializeResponse( IEnumerable<byte> input )
        {
            ResponseMessage result;
            var error =
                new ResponseMessageSerializer(
                        Arrays<IFilterProvider<ResponseMessageSerializationFilter>>.Empty,
                        Arrays<IFilterProvider<SerializedMessageFilter<MessageSerializationContext>>>.Empty,
                        Arrays<IFilterProvider<SerializedMessageFilter<MessageDeserializationContext>>>.Empty,
                        Arrays<IFilterProvider<ResponseMessageDeserializationFilter>>.Empty,
                        null
                ).Deserialize( input, out result );
            if ( !error.IsSuccess )
            {
                throw error.ToException();
            }

            return result;
        }
        public static RpcOutputBuffer SerializeResponse( int messageId, RpcException exception )
        {
            var result = new RpcOutputBuffer( ChunkBuffer.CreateDefault() );
            var error =
                new ResponseMessageSerializer(
                        Arrays<IFilterProvider<ResponseMessageSerializationFilter>>.Empty,
                        Arrays<IFilterProvider<SerializedMessageFilter<MessageSerializationContext>>>.Empty,
                        Arrays<IFilterProvider<SerializedMessageFilter<MessageDeserializationContext>>>.Empty,
                        Arrays<IFilterProvider<ResponseMessageDeserializationFilter>>.Empty,
                        null
                ).Serialize( messageId, null, false, exception, result );
            if ( !error.IsSuccess )
            {
                throw error.ToException();
            }

            return result;
        }