Table of Contents

Establishing a Connection

Once you have created an MdClientSession object (steps in MdClientSession Configuration), you can call the Connect() and Disconnect() methods to establish and close a connection to the server.

We advise you to hook up all event handlers prior to connecting to the server (see also Engagement Procedure).

There are events which clients can subscribe to in order to be notified of the connection/disconnection procedure:

mdClientSession.Connecting += OnConnecting; //Fired when the client is about to connect to the server
mdClientSession.Connected += OnConnected; //Fired when the client has successfully connected to the server
mdClientSession.Disconnecting += OnDisconnecting; //Fired when the client is about to disconnect from the server
mdClientSession.Disconnected += OnDisconnected; //Fired when the client has successfully disconnected from the server

For details on these events, see

Note

Both the Connect and Disconnect methods are non-blocking and return void. If you want to get notified about the connection success (or error) before moving on with you application logic, you can subscribe to the Connected event.

Handling Connection Errors

The MdClientSession object exposes an event to notify about connection errors. Clients can subscribe to take action when that happens:

mdClientSession.ErrorDetected += OnErrorDetected; //Fired when a socket error occurs in the library.

For details, see ErrorDetected event.