Skip to content

Rpc server programming

yfakariya edited this page Aug 19, 2012 · 2 revisions

Content

  • Public API
    • RpcServer - Single entry point for server side stack.
    • RpcServerConfiguration - Configuration API to tweak client side behavior.
  • Extension API/SPI
    • Dispatcher
    • ServiceTypeLocator
    • ServerTransportManager
    • ServerTransport
    • ServerRequestContext
    • ServerResponseContext

Public API

There are APIs which are used by applications.

RpcServer

RpcServer is entry point for the server. You can start server side listening with Start() and finish with Stop() or Dispose().

RpcServerConfiguration

RpcServerConfiguration represents configuration settings, that is this is Configuration API. If your application requires file based configuration, build RpcServerConfiguration using your configuration settings (such as custom ConfigurationSection). You can also set providers for custom Dispatcher, ServiceTypeLocator, and ServerTransportManager on the configuration.

Extension API/SPI

If you want to customize RPC, you can use following APIs (and/or SPIs).

Dispatcher

Dispatcher dispatches messages to appropriate service methods and handle thrown exception to rpc error. There is a default dispatcher called LocatorBasedDispatcher which delegates target method locating to a ServiceTypeLocator.

ServiceTypeLocator

ServiceTypeLocator locates service types and its methods in specific way. There is a default locator called DefaultServiceTypeLocator and FileBasedServiceTypeLocator. For more information, see Locating RPC Services

ServerTransportManager

ServerTransportManager manages ServerTransport lifetime. For connection oriented protocol, it handles asynchronous accept operation. Implement it if you want to implement custom transport such as additional transport protocol support. You also must implement own ServerTransport.

ServerTransport

ServerTransport represents transport session between client and server on client side. The base class implements following:

  • Serialization/deserialization.
  • Invalid (corrupt) request handling.
  • Method dispatch (Dispatcher invocation).
  • Exception translation.

Implement it if you want to implement custom transport such as additional transport protocol support. You also must implement own ServerTransportManager.

ServerRequestContext/ServerResponseContext

ServerRequestContext and ServerResponseContext encapselates context information of communication. Modifying from custom transports or filters is not supported.

Custom transports use its internal data via SocketContext property which returns SocketAsyncEventArgs.

Clone this wiki locally