Subscribe to updates on the GetVehicleLocationsAsync endpoint
You can also subscribe to the location data. The data isn't live in the sense that it isn't streamed from anywhere, the service is simply executing the GetVehicleLocationsAsync endpoint every minute behind the scenes, essentially polling for new data.
Data returned from the API is compared to data stored in an internal cache, if any new data is present, an event is raised containing the updates.
The cache service is not a data store. It's only used to present the client with updates on new data, and also to ignore data that's been received late and is out of order (due to newer items existing). It only caches the most recent data points for each vehicle, as the new data replaces the existing data as opposed to being added to the same collection.
CancellationTokenSourcects=new CancellationTokenSource(TimeSpan.FromMinutes(60));IbbClientclient=new IbbClient();// The cache service raises events notifying the client of new data.// It also ensures that data that's received out of order is ignored.VehicleLocationCacheServicecacheService=new VehicleLocationCacheService(client);
cacheService.OnVehicleLocationUpdate +=(sender,data)=>{// The event arguments contains a collection of all the updated data.// The updated elements are batched together.IEnumerable<VehiclesLocationUpdatedEventArgs>updatedData= data.UpdatedVehicleLocations; Console.WriteLine($"Elements updated: {updatedData.Count()}");};await cacheService.BeginTracking(cts.Token);
Hi there!
Thanks for putting this together, it's a great way to explore the IETT data for Istanbul. This is more a question than an issue, but I was wondering if you have any idea how to get the variations of a route?
For example: var busRouteDetails = await client.GetBusRouteDetailsAsync("9");
returns 94 results - this lines up perfectly to the information on the IETT website for line 9 over here: https://iett.istanbul/en/main/hatlar/9
However, if you look at the page there is a tab for "Bus routes faster" and if you choose a route in the combo box you get a whole different set of stop sequences. Do you think there is a way to access these variations from the API (T, U and K)? I have looked at their API docs and used the SOAP API and have not had any luck as yet.
Thanks so much for any info! Also unfortunately I don't speak Turkish so I am flying in the dark a bit!