Closed acedrew closed 10 years ago
I'm having some trouble figuring out what your issue is :) I'll attempt to explain what's going on with the two endpoints:
/buses
is a static JSON response with the latest information from CARTA. Unfortunately, there's no indication of a timestamp for when information was last received from the bus. The buses which show up on here should all be currently active, as far as I can tell from the data source. Throughout the day, buses will be added and removed from this list automatically.
/buses/tail
is a server-sent events stream with three types of events:
add
when a bus is added. On first connection, all currently active buses are sent out as add
events - similar to scrollback on reconnect for a chat client. This lets you do things immediately, such as draw the initial locations on a map.change
when any of the properties on a bus object are changed - this could be the lat/lon, the inbound/outbound segment on the route, etc.remove
when a bus goes out of service and information about that bus is no longer available from CARTA.I think it's simply an issue with CARTA's API, active for them does not necessarily mean being driven currently, more along the lines of "In rotation for the route"
Store locations of buses in a temporary list by bus ID, when connecting, pass all that have been active within n seconds to the connecting client.
I am stupid. Still stupid, but, there is an issue here, there doesn't seem to be any expiration of buses that are passed by http://api.chab.us/buses, or if there is, it's too long.