Esempio n. 1
0
        /// <summary>
        ///		Initializes a new instance of the <see cref="RpcServer"/> class with specified configuration.
        /// </summary>
        /// <param name="configuration">
        ///		The <see cref="RpcServerConfiguration"/>.
        ///		Or <c>null</c> to use default configuration.
        ///	</param>
        public RpcServer(RpcServerConfiguration configuration)
        {
            var safeConfiguration = (configuration ?? RpcServerConfiguration.Default).AsFrozen();

            this._configuration        = safeConfiguration;
            this._serializationContext = new SerializationContext();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var config = new RpcServerConfiguration();

            config.BindingEndPoint = new IPEndPoint(IPAddress.Loopback, 8089);

            config.PreferIPv4 = true;

            config.IsDebugMode = true;
            //UseFullMethodName is a property that if it is false allows you in the CLIENT to call the         methods only by it's name, check example further.
            config.UseFullMethodName = false;

            var defaultServiceTypeLocator = new DefaultServiceTypeLocator();

            //Methods is the class I created with all the methods to be called.
            defaultServiceTypeLocator.AddService(typeof(Methods));

            config.ServiceTypeLocatorProvider = conf => defaultServiceTypeLocator;

            using (var server = new RpcServer(config))
            {
                server.Start();
                Console.ReadKey();
            }
        }
Esempio n. 3
0
		internal RpcServerRuntime( RpcServerConfiguration configuration, SerializationContext serializationContext )
		{
			this._configuration = configuration;
			this._serializationContext = serializationContext;
			this._applicationContextPool =
				configuration.ApplicationContextPoolProvider(
					() => new RpcApplicationContext(
						configuration.ExecutionTimeout,
						configuration.HardExecutionTimeout
					),
				configuration.CreateApplicationContextPoolConfiguration()
			);
			this._softTimeoutDetails =
				new MessagePackObject(
					new MessagePackObjectDictionary()
					{
						{ RpcException.MessageKeyUtf8, "Execution timeout." },
						{ 
							RpcException.DebugInformationKeyUtf8, 
							String.Format( 
								CultureInfo.InvariantCulture, 
								"{{ \"ExecutionTimeout\" : \"{0}\", \"HardExecutionTimeout\" : \"{1}\" }}",
								configuration.ExecutionTimeout,
								configuration.HardExecutionTimeout
							)
						}
					},
					true
				);
		}
Esempio n. 4
0
 internal RpcServerRuntime(RpcServerConfiguration configuration, SerializationContext serializationContext)
 {
     this._configuration          = configuration;
     this._serializationContext   = serializationContext;
     this._applicationContextPool =
         configuration.ApplicationContextPoolProvider(
             () => new RpcApplicationContext(
                 configuration.ExecutionTimeout,
                 configuration.HardExecutionTimeout
                 ),
             configuration.CreateApplicationContextPoolConfiguration()
             );
     this._softTimeoutDetails =
         new MessagePackObject(
             new MessagePackObjectDictionary()
     {
         { RpcException.MessageKeyUtf8, "Execution timeout." },
         {
             RpcException.DebugInformationKeyUtf8,
             String.Format(
                 CultureInfo.InvariantCulture,
                 "{{ \"ExecutionTimeout\" : \"{0}\", \"HardExecutionTimeout\" : \"{1}\" }}",
                 configuration.ExecutionTimeout,
                 configuration.HardExecutionTimeout
                 )
         }
     },
             true
             );
 }
Esempio n. 5
0
		/// <summary>
		///		Initializes a new instance of the <see cref="RpcServer"/> class with specified configuration.
		/// </summary>
		/// <param name="configuration">
		///		The <see cref="RpcServerConfiguration"/>.
		///		Or <c>null</c> to use default configuration.
		///	</param>
		public RpcServer( RpcServerConfiguration configuration )
		{
			var safeConfiguration = ( configuration ?? RpcServerConfiguration.Default ).AsFrozen();
			this._configuration = safeConfiguration;
			this._serializationContext = new SerializationContext();
		}
 private static CallbackServer Create(RpcServerConfiguration configuration)
 {
     return(new CallbackServer(new RpcServer(configuration)));
 }
Esempio n. 7
0
		/// <summary>
		///		Creates new <see cref="RpcServerRuntime"/>.
		/// </summary>
		/// <param name="configuration">The configuration to be used. To use default, specify <c>null</c>.</param>
		/// <param name="serializationContext">The serialization context to be used. To use default, specify <c>null</c>.</param>
		/// <returns>
		///		The <see cref="RpcServerRuntime"/> instance.
		/// </returns>
		/// <remarks>
		///		This method is mainly provided for testing purposes.
		///		You should use <see cref="P:Dispatcher.Runtime"/> property instead.
		/// </remarks>
		public static RpcServerRuntime Create( RpcServerConfiguration configuration, SerializationContext serializationContext )
		{
			Contract.Ensures( Contract.Result<RpcServerRuntime>() != null );

			return new RpcServerRuntime( configuration ?? RpcServerConfiguration.Default, serializationContext ?? new SerializationContext() );
		}
Esempio n. 8
0
		private static CallbackServer Create( RpcServerConfiguration configuration )
		{
			return new CallbackServer( new RpcServer( configuration ) );
		}
Esempio n. 9
0
        /// <summary>
        ///		Creates new <see cref="RpcServerRuntime"/>.
        /// </summary>
        /// <param name="configuration">The configuration to be used. To use default, specify <c>null</c>.</param>
        /// <param name="serializationContext">The serialization context to be used. To use default, specify <c>null</c>.</param>
        /// <returns>
        ///		The <see cref="RpcServerRuntime"/> instance.
        /// </returns>
        /// <remarks>
        ///		This method is mainly provided for testing purposes.
        ///		You should use <see cref="P:Dispatcher.Runtime"/> property instead.
        /// </remarks>
        public static RpcServerRuntime Create(RpcServerConfiguration configuration, SerializationContext serializationContext)
        {
            Contract.Ensures(Contract.Result <RpcServerRuntime>() != null);

            return(new RpcServerRuntime(configuration ?? RpcServerConfiguration.Default, serializationContext ?? new SerializationContext()));
        }