/// <summary> /// Stops the MTS Session detaches all events registered and disposes the session /// </summary> public void Stop() { _log.Info("Detaching from events"); DetachFromFeedEvents(_mtsSdk); _log.Info("Closing the connection and disposing the instance"); _mtsSdk.Close(); _log.Info("MTS SDK stopped."); }
public void Run() { _log.LogInformation("Running the MTS SDK cashout example"); _log.LogInformation("Retrieving configuration from application configuration file"); var config = MtsSdk.GetConfiguration(); _log.LogInformation("Creating root MTS SDK instance"); _mtsSdk = new MtsSdk(config, _loggerFactory); _log.LogInformation("Attaching to events"); AttachToFeedEvents(_mtsSdk); _log.LogInformation("Opening the sdk instance (creating and opening connection to the AMPQ broker)"); _mtsSdk.Open(); _factory = _mtsSdk.BuilderFactory; // create ticket (in order to be accepted, correct values must be entered) // values below are just for demonstration purposes and will not be accepted //cashout ticket is available only for live events var r = new Random(); _originalTicket = _factory.CreateTicketBuilder() .SetTicketId("ticketId-" + r.Next()) .SetSender(_factory.CreateSenderBuilder() .SetCurrency("EUR") .SetEndCustomer(_factory.CreateEndCustomerBuilder() .SetId("customerClientId-" + r.Next()) .SetConfidence(1) .SetIp(IPAddress.Loopback) .SetLanguageId("en") .SetDeviceId("UsersDevice-" + r.Next()) .Build()) .Build()) .AddBet(_factory.CreateBetBuilder() .SetBetId("betId-" + r.Next()) .SetBetBonus(1) .SetStake(123450000, StakeType.Total) .AddSelectedSystem(1) .AddSelection(_factory.CreateSelectionBuilder() .SetEventId("1") .SetIdUof(1, $"sr:match:{r.Next()}", 1, "1", string.Empty, null) .SetOdds(11000) .Build()) .Build()) .BuildTicket(); // send ticket to the MTS. Since this is a non-blocking way of sending, the response will raise the event TicketResponseReceived _log.LogInformation("Send ticket to the MTS."); _mtsSdk.SendTicket(_originalTicket); _log.LogInformation("Example successfully executed. Hit <enter> to quit"); Console.WriteLine(string.Empty); Console.ReadLine(); _log.LogInformation("Detaching from events"); DetachFromFeedEvents(_mtsSdk); _log.LogInformation("Closing the connection and disposing the instance"); _mtsSdk.Close(); _log.LogInformation("Example stopped"); }
public void Run() { _log.Info("Running the MTS SDK Basic example"); _log.Info("Retrieving configuration from application configuration file"); var config = MtsSdk.GetConfiguration(); _log.Info("Creating root MTS SDK instance"); _mtsSdk = new MtsSdk(config); _log.Info("Attaching to events"); AttachToFeedEvents(_mtsSdk); _log.Info("Opening the sdk instance (creating and opening connection to the AMPQ broker)"); _mtsSdk.Open(); _factory = _mtsSdk.BuilderFactory; // create ticket (in order to be accepted, correct values must be entered) // values below are just for demonstration purposes and will not be accepted var r = new Random(); var ticket = _factory.CreateTicketBuilder() .SetTicketId("ticketId-" + r.Next()) .SetSender(_factory.CreateSenderBuilder() .SetCurrency("EUR") .SetEndCustomer(_factory.CreateEndCustomerBuilder() .SetId("customerClientId-" + r.Next()) .SetConfidence(1) .SetIp(IPAddress.Loopback) .SetLanguageId("en") .SetDeviceId("UsersDevice-" + r.Next()) .Build()) .Build()) .AddBet(_factory.CreateBetBuilder() .SetBetId("betId-" + r.Next()) .SetBetBonus(1) .SetStake(15000, StakeType.Total) .AddSelectedSystem(1) .AddSelection(_factory.CreateSelectionBuilder() .SetEventId("1") .SetIdUof(3, $"sr:match:{r.Next()}", 12, "1", string.Empty, null) .SetOdds(11000) .Build()) .Build()) .BuildTicket(); // send ticket to the MTS. Since this is a blocking way of sending, the response will be result of the method (no event handler will be raised) _log.Info("Send ticket to the MTS and wait for the response."); var ticketResponse = _mtsSdk.SendTicketBlocking(ticket); _log.Info($"TicketResponse received. Status={ticketResponse.Status}, Reason={ticketResponse.Reason.Message}."); if (ticketResponse.Status == TicketAcceptance.Accepted) { //required only if 'explicit acking' is enabled in MTS admin ticketResponse.Acknowledge(); //if for some reason we want to cancel ticket, this is how we can do it var ticketCancel = _factory.CreateTicketCancelBuilder().BuildTicket(ticket.TicketId, ticket.Sender.BookmakerId, TicketCancellationReason.BookmakerTechnicalIssue); var ticketCancelResponse = _mtsSdk.SendTicketCancelBlocking(ticketCancel); _log.Info($"Ticket '{ticket.TicketId}' response is {ticketCancelResponse.Status}. Reason={ticketCancelResponse.Reason?.Message}"); if (ticketCancelResponse.Status == TicketCancelAcceptance.Cancelled) { //mandatory for all cancellations, except for TimeOutTriggered cancellation ticketCancelResponse.Acknowledge(); } } _log.Info("Example successfully executed. Hit <enter> to quit"); Console.WriteLine(string.Empty); Console.ReadLine(); _log.Info("Detaching from events"); DetachFromFeedEvents(_mtsSdk); _log.Info("Closing the connection and disposing the instance"); _mtsSdk.Close(); _log.Info("Example stopped"); }
public void Run() { _log.Info("Running the MTS SDK Basic example"); _log.Info("Retrieving configuration from application configuration file"); var config = MtsSdk.GetConfiguration(); _log.Info("Creating root MTS SDK instance"); _mtsSdk = new MtsSdk(config); _log.Info("Attaching to events"); AttachToFeedEvents(_mtsSdk); _log.Info("Opening the sdk instance (creating and opening connection to the AMPQ broker)"); _mtsSdk.Open(); _factory = _mtsSdk.BuilderFactory; // create ticket (in order to be accepted, correct values must be entered) // values below are just for demonstration purposes and will not be accepted var r = new Random(); var bet = _factory.CreateBetBuilder() .SetBetId("betId-" + r.Next()) .SetBetBonus(1) .SetStake(11200, StakeType.Total) .AddSelectedSystem(1) .AddSelection(_factory.CreateSelectionBuilder() .SetEventId("1") .SetIdUof(3, $"sr:match:{r.Next()}", 12, "1", string.Empty, null) // only one of the following is required to set selectionId (if you use this method, config property 'accessToken' must be provided) .SetIdLo(1, 1, "1:1", "1") .SetIdLcoo(1, 1, "1:1", "1") .SetId("lcoo:409/1/*/YES") .SetOdds(11000) .Build()) .Build(); var endCustomer = _factory.CreateEndCustomerBuilder() .SetId("customerClientId-" + r.Next()) .SetConfidence(1) .SetIp(IPAddress.Loopback) .SetLanguageId("en") .SetDeviceId("UsersDevice-" + r.Next()) .Build(); var ticket = _factory.CreateTicketBuilder() .SetTicketId("ticketId-" + r.Next()) .SetSender(_factory.CreateSenderBuilder() .SetCurrency("EUR") .SetEndCustomer(endCustomer) .Build()) .AddBet(bet) .BuildTicket(); // send ticket to the MTS. Since this is a non-blocking way of sending, the response will come on the event TicketResponseReceived _log.Info("Send ticket to the MTS."); _log.Info(ticket.ToJson()); _mtsSdk.SendTicket(ticket); _log.Info("Example successfully executed. Hit <enter> to quit"); Console.WriteLine(string.Empty); Console.ReadLine(); _log.Info("Detaching from events"); DetachFromFeedEvents(_mtsSdk); _log.Info("Closing the connection and disposing the instance"); _mtsSdk.Close(); _log.Info("Example stopped"); }
public void Run() { _log.LogInformation("Running the MTS SDK ticket integration examples"); _log.LogInformation("Retrieving configuration from application configuration file"); var config = MtsSdk.GetConfiguration(); _log.LogInformation("Creating root MTS SDK instance"); _mtsSdk = new MtsSdk(config, _loggerFactory); _log.LogInformation("Attaching to events"); AttachToFeedEvents(_mtsSdk); _log.LogInformation("Opening the sdk instance (creating and opening connection to the AMPQ broker)"); _mtsSdk.Open(); var ticketExamples = new TicketExamples(_mtsSdk.BuilderFactory); _factory = _mtsSdk.BuilderFactory; _log.LogInformation("Example 1"); _mtsSdk.SendTicket(ticketExamples.Example1()); _log.LogInformation("Example 2"); _mtsSdk.SendTicket(ticketExamples.Example2()); _log.LogInformation("Example 3"); _mtsSdk.SendTicket(ticketExamples.Example3()); _log.LogInformation("Example 4"); _mtsSdk.SendTicket(ticketExamples.Example4()); _log.LogInformation("Example 5"); _mtsSdk.SendTicket(ticketExamples.Example5()); _log.LogInformation("Example 6"); _mtsSdk.SendTicket(ticketExamples.Example6()); _log.LogInformation("Example 7"); _mtsSdk.SendTicket(ticketExamples.Example7()); _log.LogInformation("Example 8"); _mtsSdk.SendTicket(ticketExamples.Example8()); _log.LogInformation("Example 9"); _mtsSdk.SendTicket(ticketExamples.Example9()); _log.LogInformation("Example 10"); _mtsSdk.SendTicket(ticketExamples.Example10()); _log.LogInformation("Example 11"); _mtsSdk.SendTicket(ticketExamples.Example11()); _log.LogInformation("Example 12"); _mtsSdk.SendTicket(ticketExamples.Example12()); _log.LogInformation("Example 13"); _mtsSdk.SendTicket(ticketExamples.Example13()); _log.LogInformation("Example 14"); _mtsSdk.SendTicket(ticketExamples.Example14()); _log.LogInformation("Examples successfully executed. Hit <enter> to quit"); Console.WriteLine(string.Empty); Console.ReadLine(); _log.LogInformation("Detaching from events"); DetachFromFeedEvents(_mtsSdk); _log.LogInformation("Closing the connection and disposing the instance"); _mtsSdk.Close(); _log.LogInformation("Example stopped"); }