Ejemplo n.º 1
0
        void GetDevicesInView(IARequest request, IAResponse response)
        {
            String deviceIdentifier = request.Parameters["identifier"];

            // Find the associated device in the Current Devices
            Device observer = locator.Devices.Find(d => d.Identifier.Equals(deviceIdentifier));

            if (observer == null)
            {
                response.StatusCode = 404;
                return;
            }

            // Get the devices in view, and convert them for serialization
            List <Device>             devicesInView = locator.GetDevicesInView(observer);
            List <IntermediateDevice> intDevices    = PairableDevice.GetCompleteIntermediateDevicesList(devicesInView);

            if (intDevices.Count == 0)
            {
                response.StatusCode = 404;
                return;
            }

            response.SetBodyWith(intDevices);
        }
Ejemplo n.º 2
0
        void GetDevicesInRange(IARequest request, IAResponse response)
        {
            String deviceIdentifier = request.Parameters["identifier"];
            double range            = Double.Parse(request.Parameters["range"]);

            // Find the associated device in the Current Devices
            Device device = locator.Devices.Find(d => d.Identifier.Equals(deviceIdentifier));

            if (device == null)
            {
                response.StatusCode = 404;
                return;
            }

            List <Device>             devicesInView       = locator.GetDevicesWithinRange(device, range);
            List <IntermediateDevice> intermediateDevices = PairableDevice.GetCompleteIntermediateDevicesList(devicesInView);

            if (intermediateDevices.Count == 0)
            {
                response.StatusCode = 404;
                return;
            }

            // Respond with the device
            response.SetBodyWith(intermediateDevices);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return All Devices known to the Locator
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        void GetDevices(IARequest request, IAResponse response)
        {
            List <IntermediateDevice> intermediateDevices = PairableDevice.GetCompleteIntermediateDevicesList(locator.Devices);

            if (intermediateDevices.Count == 0)
            {
                response.StatusCode = 404;
            }
            else
            {
                response.SetBodyWith(intermediateDevices);
            }
        }