Example #1
0
 public InProcTestEnvironment(Func <int?, MessagePackObject[], MessagePackObject> callback)
 {
     this._endPoint      = new IPEndPoint(IPAddress.Loopback, MsgPack.Rpc.Server.CallbackServer.PortNumber);
     this._server        = MsgPack.Rpc.Server.CallbackServer.Create(callback, true);
     this._configuration = RpcClientConfiguration.Default.Clone();
     this._configuration.TransportManagerProvider = conf => this._clientTransportManager;
     this._configuration.Freeze();
     this._serverTransportManager = new MsgPack.Rpc.Server.Protocols.InProcServerTransportManager(this._server.Server as Server.RpcServer, mgr => new SingletonObjectPool <Server.Protocols.InProcServerTransport>(new Server.Protocols.InProcServerTransport(mgr)));
     this._clientTransportManager = new InProcClientTransportManager(new RpcClientConfiguration(), this._serverTransportManager);
 }
        /// <summary>
        ///		Initializes a new instance of the <see cref="RpcClient"/> class.
        /// </summary>
        /// <param name="targetEndPoint">
        ///		<see cref="EndPoint"/> for the target.
        /// </param>
        /// <param name="configuration">
        ///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
        /// </param>
        /// <param name="serializationContext">
        ///		A <see cref="SerializationContext"/> to hold serializers.
        ///	</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="targetEndPoint"/> is <c>null</c>.
        /// </exception>
        public RpcClient(EndPoint targetEndPoint, RpcClientConfiguration configuration, SerializationContext serializationContext)
        {
            if (targetEndPoint == null)
            {
                throw new ArgumentNullException("targetEndPoint");
            }

            Contract.EndContractBlock();

            var safeConfiguration = configuration ?? RpcClientConfiguration.Default;

            this._transportManager     = safeConfiguration.TransportManagerProvider(safeConfiguration);
            this._serializationContext = serializationContext ?? new SerializationContext();
            Interlocked.Exchange(ref this._connectTask, this._transportManager.ConnectAsync(targetEndPoint));
        }
Example #3
0
		/// <summary>
		///		Initializes a new instance of the <see cref="DynamicRpcProxy"/> class.
		/// </summary>
		/// <param name="targetEndPoint">
		///		<see cref="EndPoint"/> for the target.
		/// </param>
		/// <param name="configuration">
		///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
		/// </param>
		/// <param name="serializationContext">
		///		A <see cref="SerializationContext"/> to hold serializers.
		///	</param>
		/// <exception cref="ArgumentNullException">
		///		<paramref name="targetEndPoint"/> is <c>null</c>.
		/// </exception>
		public DynamicRpcProxy( EndPoint targetEndPoint, RpcClientConfiguration configuration, SerializationContext serializationContext )
			: this( new RpcClient( targetEndPoint, configuration, serializationContext ) ) { }
Example #4
0
		/// <summary>
		///		Initializes a new instance of the <see cref="DynamicRpcProxy"/> class.
		/// </summary>
		/// <param name="targetEndPoint">
		///		<see cref="EndPoint"/> for the target.
		/// </param>
		/// <param name="configuration">
		///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
		/// </param>
		/// <exception cref="ArgumentNullException">
		///		<paramref name="targetEndPoint"/> is <c>null</c>.
		/// </exception>
		public DynamicRpcProxy( EndPoint targetEndPoint, RpcClientConfiguration configuration )
			: this( new RpcClient( targetEndPoint, configuration ) ) { }
Example #5
0
		/// <summary>
		///		Initializes a new instance of the <see cref="RpcClient"/> class.
		/// </summary>
		/// <param name="targetEndPoint">
		///		<see cref="EndPoint"/> for the target.
		/// </param>
		/// <param name="configuration">
		///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
		/// </param>
		/// <param name="serializationContext">
		///		A <see cref="SerializationContext"/> to hold serializers.
		///	</param>
		/// <exception cref="ArgumentNullException">
		///		<paramref name="targetEndPoint"/> is <c>null</c>.
		/// </exception>
		public RpcClient( EndPoint targetEndPoint, RpcClientConfiguration configuration, SerializationContext serializationContext )
		{
			if ( targetEndPoint == null )
			{
				throw new ArgumentNullException( "targetEndPoint" );
			}

			Contract.EndContractBlock();

			var safeConfiguration = configuration ?? RpcClientConfiguration.Default;

			this._transportManager = safeConfiguration.TransportManagerProvider( safeConfiguration );
			this._serializationContext = serializationContext ?? new SerializationContext();
			Interlocked.Exchange( ref this._connectTask, this._transportManager.ConnectAsync( targetEndPoint ) );
		}
Example #6
0
		/// <summary>
		///		Initializes a new instance of the <see cref="RpcClient"/> class.
		/// </summary>
		/// <param name="targetEndPoint">
		///		<see cref="EndPoint"/> for the target.
		/// </param>
		/// <param name="configuration">
		///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
		/// </param>
		/// <exception cref="ArgumentNullException">
		///		<paramref name="targetEndPoint"/> is <c>null</c>.
		/// </exception>
		public RpcClient( EndPoint targetEndPoint, RpcClientConfiguration configuration ) : this( targetEndPoint, configuration, null ) { }
Example #7
0
			public InProcTestEnvironment( Func<string, int?, MessagePackObject[], MessagePackObject> callback )
			{
				this._endPoint = new IPEndPoint( IPAddress.Loopback, MsgPack.Rpc.Server.CallbackServer.PortNumber );
				this._server = MsgPack.Rpc.Server.CallbackServer.Create( callback, true );
				this._configuration = RpcClientConfiguration.Default.Clone();
				this._configuration.TransportManagerProvider = conf => this._clientTransportManager;
				this._configuration.Freeze();
				this._serverTransportManager = new MsgPack.Rpc.Server.Protocols.InProcServerTransportManager( this._server.Server as Server.RpcServer, mgr => new SingletonObjectPool<Server.Protocols.InProcServerTransport>( new Server.Protocols.InProcServerTransport( mgr ) ) );
				this._clientTransportManager = new InProcClientTransportManager( new RpcClientConfiguration(), this._serverTransportManager );
			}
Example #8
0
 /// <summary>
 ///		Initializes a new instance of the <see cref="DynamicRpcProxy"/> class.
 /// </summary>
 /// <param name="targetEndPoint">
 ///		<see cref="EndPoint"/> for the target.
 /// </param>
 /// <param name="configuration">
 ///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
 /// </param>
 /// <param name="serializationContext">
 ///		A <see cref="SerializationContext"/> to hold serializers.
 ///	</param>
 /// <exception cref="ArgumentNullException">
 ///		<paramref name="targetEndPoint"/> is <c>null</c>.
 /// </exception>
 public DynamicRpcProxy(EndPoint targetEndPoint, RpcClientConfiguration configuration, SerializationContext serializationContext)
     : this(new RpcClient(targetEndPoint, configuration, serializationContext))
 {
 }
Example #9
0
 /// <summary>
 ///		Initializes a new instance of the <see cref="DynamicRpcProxy"/> class.
 /// </summary>
 /// <param name="targetEndPoint">
 ///		<see cref="EndPoint"/> for the target.
 /// </param>
 /// <param name="configuration">
 ///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
 /// </param>
 /// <exception cref="ArgumentNullException">
 ///		<paramref name="targetEndPoint"/> is <c>null</c>.
 /// </exception>
 public DynamicRpcProxy(EndPoint targetEndPoint, RpcClientConfiguration configuration)
     : this(new RpcClient(targetEndPoint, configuration))
 {
 }
Example #10
0
 /// <summary>
 ///		Initializes a new instance of the <see cref="RpcClient"/> class.
 /// </summary>
 /// <param name="targetEndPoint">
 ///		<see cref="EndPoint"/> for the target.
 /// </param>
 /// <param name="configuration">
 ///		A <see cref="RpcClientConfiguration"/> which contains protocol information etc.
 /// </param>
 /// <exception cref="ArgumentNullException">
 ///		<paramref name="targetEndPoint"/> is <c>null</c>.
 /// </exception>
 public RpcClient(EndPoint targetEndPoint, RpcClientConfiguration configuration) : this(targetEndPoint, configuration, null)
 {
 }