Click or drag to resize

How to start

Below are basic examples that can help you start using sdk. For more advance topics refer to sdk example.

A basic way to use the OddsFeed

To receive sdk events/messages subscribe to all IOddsFeed and IEntityDispatcherT events.

Note that there is one thread handling message reception and calling your event handler per session, so the processing within that method should be as quick as possible to not prevent following messages from being processed.
It is recommended that all ISportEvent processing is done in separate thread.

Below example is the minimum setup to start receiving messages. Note that you open only once, process messages for as long as you want, and then close the feed.

C#
var config = Feed.GetConfigurationBuilder().BuildFromConfigFile();

var oddsFeed = new Feed(config);

var session = oddsFeed.CreateBuilder().SetMessageInterest(MessageInterest.AllMessages).Build();

oddsFeed.ProducerUp += OnProducerUp;
oddsFeed.ProducerDown += OnProducerDown;
oddsFeed.Disconnected += OnDisconnected;
oddsFeed.Closed += OnClosed;

session.OnUnparsableMessageReceived += SessionOnUnparsableMessageReceived;
session.OnBetCancel += SessionOnBetCancel;
session.OnBetSettlement += SessionOnBetSettlement;
session.OnBetStop += SessionOnBetStop;
session.OnFixtureChange += SessionOnFixtureChange;
session.OnOddsChange += SessionOnOddsChange;
session.OnRollbackBetCancel += SessionOnRollbackBetCancel;
session.OnRollbackBetSettlement += SessionOnRollbackBetSettlement;

oddsFeed.Open();
Advanced way to use the OddsFeed

Another more scalable way of handling feed messages is to have different sessions for different MessageInterest.
If you wish to only process live events in one system and maybe process prematch events in a completely different system, you can do this in a similar manner.

Note that only some of the combination are allowed (i.e. LiveMessagesOnly and PrematchMessagesOnly or HighPriorityMessages and LowPriorityMessages and so on).
To create two different sessions for the LiveMessagesOnly and PrematchMessagesOnly messages you do the following:

C#
var config = Feed.GetConfigurationBuilder().BuildFromConfigFile();

var oddsFeed = new Feed(config);

AttachToFeedEvents(oddsFeed);

var sessionLive = oddsFeed.CreateBuilder().SetMessageInterest(MessageInterest.LiveMessagesOnly).Build();
var sessionPre = oddsFeed.CreateBuilder().SetMessageInterest(MessageInterest.PrematchMessagesOnly).Build();

AttachToSessionEvents(sessionLive);
AttachToSessionEvents(sessionPre);

oddsFeed.Open();
Disabling producers

Before opening the IOddsFeed instance, you can setup to receive feed messages only for specific producer by disabling all others.

C#
oddsFeed.ProducerManager.DisableProducer(1);
System Failures

The Unified Odds SDK is designed to help you to detect and handle various networking outages and Sportradar subsystem failures.

If some malfunction of the system is detected (Sportradar subsystem stops working, alive interval violations,...), the SDK will dispatch a ProducerDown event. When this happens it is advised that you disable all the markets related to this producer.

When the SDK detects that the malfunction is corrected it will automatically reconnect and request the most recent odds information and any other missed feed messages (a recovery request will be executed), after the recovery is completed the ProducerUp event is dispatched. After that the producer is up again and you can safely re-enable all the markets.

If your system crashes or if you take down/restart your system you need to provide the timestamp of the last processed message per producer, so the SDK performs the recovery for the missed messages (the max time from the last processed message varies per producer; i.e. for prematch producer can not be more than 3 days).

You can do this through the ProducerManager available on the IOddsFeed instance. If the last processed message timestamp is not provided, the SDK will perform a full recovery.
Beware: with a full recovery you do not recover any lost BetSettlement messages.

C#
oddsFeed.ProducerManager.AddTimestampBeforeDisconnect(1, DateTime.Now.AddMinutes(-10));
oddsFeed.ProducerManager.AddTimestampBeforeDisconnect(3, DateTime.Now.AddMinutes(-10));
See Also