private void OnServiceFound(SDService service, bool ownService) { if (ownService) { IADevice device = new IADevice(service.Name, service.Hostname, service.Port, this.SupportedRoutes); this.OwnDevice = device.AsOption(); OnDeviceFound(device, true); } else { IADevice device = new IADevice(service.Name, service.Hostname, service.Port, null); IARequest request = new IARequest(IARoute.Get("/routes")); SendRequest(request, device, delegate(IAResponse response, Exception error) { if (error == null) { if (response.StatusCode == 200) { List <IARoute> supportedRoutes = response.BodyAs <IARoute>(); IADevice deviceWithRoutes = new IADevice(service.Name, service.Hostname, service.Port, new HashSet <IARoute>(supportedRoutes)); this.devices.Add(deviceWithRoutes); OnDeviceFound(deviceWithRoutes, false); } else { Console.WriteLine(String.Format("An error ocurred trying to request routes from {0}", device)); } } else { Console.WriteLine(String.Format("An error ocurred: {0}", error)); } }); } }
public IARequest(IARoute route, Dictionary <String, String> metadata, Dictionary <String, String> parameters, IADevice origin, byte[] body, string contentType) : base(body, contentType) { this.Route = route; this.Metadata = metadata; this.Parameters = parameters; this.Origin = origin.AsOption(); }