Table of Contents

MdClientSession Configuration

You need to instanciate an MdClientSession object in order to connect to the feed handler, which is done as follows.

Note

From version 5.0.0 onwards, the session class comes in two versions: MdClientSession and MdClientSessionV2. We created the MdClientSessionV2 variant specially for UI applications to allow wrapping the session events as Observables to facilitate the use of Reactive Extensions The MdClientSession class is the same as the previous versions of the library, and it is recommended for console applications and services which passes the updates to clients via reference (avoiding struct copies).

1. Create SessionConfiguration object

Before creating an MdClientSession instance, first you need an SessionConfiguration object storing connection properties, namely:

  • HostAddress: The IP address in string format, e.g. "192.168.11.75" of the feed handler host. This will be provided by Tooq.
  • HostPort: The port of the feed handler instance in int format. This will be provided by Tooq.
  • ReceiveBufferSize: Optional value indicating the Receive buffer size of the TCP socket. Default value is 8192. This value should not be changed without prior consultation with Tooq.
  • SendBufferSize: Optional value indicating the Sending buffer size of the TCP socket. Default value is 8192. This value should not be changed without prior consultation with Tooq.
  • ShouldReconnectAutomatically: A boolean value indicating whether the MdClientSession should reconnect automatically when connection is lost. The default is true.
  • HeartbeatInterval: Optional value indicating the interval in seconds for the heartbeat messages. Default value is 30. This value should not be changed without prior consultation with Tooq.
var sessionConfiguration = new SessionConfiguration(hostAddress: "100.64.0.53", hostPort: 10004, shouldReconnectAutomatically: true, heartbeatInterval: 30);

2. Create MdClientSession object

Pass the previously created sessionConfiguration as a parameter to create an MdClientSession object:

var mdClientSession = new MdClientSession(sessionConfiguration);

3. (Optional) Implementing ILogger interface

You can optionally define a concrete implementation of the ILogger interface to direct library relevant logs to your own logging system. In this case, your custom logger object is passed as a parameter together with sessionConfiguration:

var sessionConfiguration = new SessionConfiguration(hostAddress: "100.64.0.53", hostPort: 10004, shouldReconnectAutomatically: true);
Tooq.Tech.FH.ClientLib.ILogger logger = new CustomConcreteLogger(); // Concrete implementation of ILogger interface.
var mdClientSession = new MdClientSession(sessionConfiguration, logger); // Passing `logger` as a second parameter.