Table of Contents

Interface IConnectionProvider

Namespace
Sportradar.LiveData.Sdk.Common.Interfaces
Assembly
Sportradar.LiveData.Sdk.dll

Connection provider

public interface IConnectionProvider

Properties

ConnectionData

Obtain current connection data

IConnectionData ConnectionData { get; }

Property Value

IConnectionData

IsStarted

Obtain whether the connection provider is running.

bool IsStarted { get; }

Property Value

bool

RxEnabled

Whether reading from input stream is enabled or not (i.e. input msg queue going over the high watermark should disable all RX)

ManualResetEventSlim RxEnabled { get; }

Property Value

ManualResetEventSlim

Methods

Error(string, string)

Start immediate error recovery. Usually due to an error on the upper layer.

[Obsolete]
void Error(string opt_protocol_message, string log_message)

Parameters

opt_protocol_message string

Optional message that should be sent before disconnection

log_message string

Informative error description

IsReceiveThread()

bool IsReceiveThread()

Returns

bool

SendMessage(string, bool)

Deliver a protocol unit (as a string) to the server.

bool SendMessage(string message, bool only_try = false)

Parameters

message string

protocol unit (in string format)

only_try bool

when true do not throw any exceptions

Returns

bool

Exceptions

DisconnectedStateException

If we are currently disconnected

Start()

Start the connection provider (connects to the server and start the automatic reconnection). ConnectionData must be initialized or else an exception is thrown.

void Start()

Start(IConnectionData)

Start the connection provider (connects to the server and start the automatic reconnection).

void Start(IConnectionData connection_data)

Parameters

connection_data IConnectionData

connection data

Stop(string)

Stop the connection provider. Opposite of Start().

void Stop(string opt_protocol_message)

Parameters

opt_protocol_message string

Optional message that should be sent before disconnection

WaitForConnection()

Block and wait until the connection is established.

bool WaitForConnection()

Returns

bool

true if the connection is established; false (should rarely happen) in case of a race-condition or when wait_time times out

Remarks

The method might return true and the connection can get broken right after that, so do not assume after that method we are for sure in a "connected" state, it might have been just a temporary state.

WaitForConnection(TimeSpan)

bool WaitForConnection(TimeSpan wait_time)

Parameters

wait_time TimeSpan

Returns

bool

WaitForDisconnection()

Block and wait until the connection is not established anymore.

bool WaitForDisconnection()

Returns

bool

WaitForDisconnection(TimeSpan)

bool WaitForDisconnection(TimeSpan wait_time)

Parameters

wait_time TimeSpan

Returns

bool

Events

OnAliveCheckNecessary

Invoked when the protocol requires an alive check.

event ConnectionProviderDelegates.AliveCheckNecessaryDelegate OnAliveCheckNecessary

Event Type

ConnectionProviderDelegates.AliveCheckNecessaryDelegate

OnCommunicationError

Invoked when a communication error on the physical connection is detected

event ConnectionProviderDelegates.CommunicationErrorDelegate OnCommunicationError

Event Type

ConnectionProviderDelegates.CommunicationErrorDelegate

OnConnected

Invoked when the physical connection to the server is established.

event ConnectionProviderDelegates.ConnectionDelegate OnConnected

Event Type

ConnectionProviderDelegates.ConnectionDelegate

OnDisconnected

Invoked when the physical connection to the server is dropped.

event ConnectionProviderDelegates.ConnectionDelegate OnDisconnected

Event Type

ConnectionProviderDelegates.ConnectionDelegate

OnMessageReceived

Invoked when a new protocol data unit in string format is received.

event ConnectionProviderDelegates.DataReceivedDelegate OnMessageReceived

Event Type

ConnectionProviderDelegates.DataReceivedDelegate

OnValidDataCheckNecessary

Invoked when the protocol requires a check for valid data.

event ConnectionProviderDelegates.ValidDataCheckNecessaryDelegate OnValidDataCheckNecessary

Event Type

ConnectionProviderDelegates.ValidDataCheckNecessaryDelegate