public void ArrivalsForStop(GeoCoordinate location, Stop stop, ArrivalsForStop_Callback callback) { string requestUrl = string.Format( "{0}/{1}/{2}.xml?minutesAfter={3}&key={4}&Version={5}", WebServiceUrlForLocation(location), "arrivals-and-departures-for-stop", stop.id, 60, KEY, APIVERSION ); HttpWebRequest requestGetter = (HttpWebRequest)HttpWebRequest.Create(requestUrl); requestGetter.BeginGetResponse( new AsyncCallback(new GetArrivalsForStopCompleted(requestUrl, callback).HttpWebRequest_Completed), requestGetter); }
public void ArrivalsForStop(GeoCoordinate location, Stop stop, ArrivalsForStop_Callback callback) { string requestUrl = string.Format( "{0}/{1}/{2}.xml?minutesAfter={3}&key={4}&Version={5}", WebServiceUrlForLocation(location), "arrivals-and-departures-for-stop", stop.id, 60, KEY, APIVERSION ); WebRequest arrivalsForStopRequest = WebRequest.Create(requestUrl); arrivalsForStopRequest.BeginGetResponse(asyncResult => { XDocument xmlResponse = null; List <ArrivalAndDeparture> arrivals = new List <ArrivalAndDeparture>(); try { xmlResponse = ValidateWebCallback(asyncResult); arrivals.AddRange(from arrival in xmlResponse.Descendants("arrivalAndDeparture") select ParseArrivalAndDeparture(arrival)); } catch (WebserviceResponseException) { } catch (Exception ex) { Exception error = new WebserviceParsingException(requestUrl, xmlResponse.ToString(), ex); throw error; } callback(arrivals); }, arrivalsForStopRequest); }
public GetArrivalsForStopCompleted(string requestUrl, ArrivalsForStop_Callback callback) : base(requestUrl) { this.callback = callback; }