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);
     });
 }
Beispiel #2
0
 private async void Service_OnTelemetryArrived(object sender, TransportLocationData e)
 {
     if (!canRunJs)
     {
         return;
     }
     await ClientRuntime.InvokeVoidAsync("telemetryArrived", new[] { e });
 }