public IDisposable Subscribe(Action <TPayload> callback, SynchronizationContext synchronizationContext = null, ThreadOption threadOption = ThreadOption.Default, bool keepReferenceAlive = false) { if (callback == null) { throw new ArgumentNullException(nameof(callback)); } lock (Subscribers) { var sub = new EventSub(callback, synchronizationContext, this, keepReferenceAlive); Subscribers.Add(sub); return(sub); } }
public LineDTO CreateLine(EventSub @event, string host, string name) { try { if ([email protected]("started")) { return(null); } @event.Event.sport = Helper.ConvertSport(@event.Event.sport); if (!int.TryParse(@event.LiveData.score.home, out var s1) || !int.TryParse(@event.LiveData.score.away, out var s2)) { return(null); } var line = new LineDTO { BookmakerName = name, SportKind = @event.Event.sport, Team1 = @event.Event.homeName, Team2 = @event.Event.awayName, Url = $"{host}offering/v2018/888/betoffer/event/{@event.Event.id}.json?lang=en_GB&market=en", Score1 = s1, Score2 = s2, //CoeffType = @event.event_result_name.ToLower(), EventDate = DateTime.Now, LineObject = JsonConvert.SerializeObject(@event) }; return(line); } catch (Exception e) { Log.Info("888sport CreateLine exception " + JsonConvert.SerializeObject(e) + Environment.NewLine + JsonConvert.SerializeObject(@event)); } return(null); }
private List <LineDTO> ParseEvent(EventSub @event) { var random = ProxyList.PickRandom(); try { var converter = new S888LineConverter(); var lineTemplate = converter.CreateLine(@event, Host, Name); if (lineTemplate == null) { return(new List <LineDTO>()); } var eventFull = ConverterHelper.GetFullLine(@event.Event.id, random, Host); if (eventFull == null) { return(new List <LineDTO>()); } return(converter.GetLinesFromEvent(lineTemplate, eventFull)); } catch (WebException e) { Log.Info("888sport WebException " + JsonConvert.SerializeObject(e)); ParseEvent(@event); } catch (Exception e) { Log.Info("888sport Parse event exception " + JsonConvert.SerializeObject(e)); } return(new List <LineDTO>()); }