コード例 #1
0
 public void StartProvidingTelemetry()
 {
     SockJS = new SockJS(EndpointConfiguration.Value.Url);
     SockJS.AddEventListener("open", (sender, e) =>
     {
         SockJS.Send(EndpointConfiguration.Value.ConnectionString);
     });
     SockJS.AddEventListener("message", (sender, obj) =>
     {
         if (obj[0] is TransportMessageEvent msg)
         {
             var dataString = msg.Data.ToString();
             if (dataString.Contains("No subscription found"))
             {
                 return;
             }
             var conn = dataString.StartsWith("CONNECTED");
             canSend |= conn;
             if (conn)
             {
                 SubscriptionModels.ToList().ForEach(ProcessChanges);
             }
             var kk = TransportLocationData.FromJson(dataString);
             if (kk is null)
             {
                 return;
             }
             OnTelemetryArrived?.Invoke(this, kk);
         }
     });
     SockJS.AddEventListener("close", (sender, e) =>
     {
         Task.Run(StartProvidingTelemetry);
     });
 }
コード例 #2
0
 public TransportDataProviderService(IOptions <EndpointConfiguration> EndpointConfiguration)
 {
     this.EndpointConfiguration = EndpointConfiguration;
     OnSubscriptionListChanged  = (b) => { SubscriptionModels.Add(b); ProcessChanges(b); };
 }