コード例 #1
0
ファイル: MSELocator.cs プロジェクト: ase-lab/MSEAPI-CS
        public void UpdateDeviceOrientation(MSEDevice device, MSESuccessHandler success, MSEErrorHandler failure)
        {
            IARequest request = new IARequest(Routes.SetOrientationRoute);
            request.SetBodyWithString(device.Orientation.Value.ToString());
            request.Parameters["identifier"] = device.Identifier;

            IEnumerable devicesSupportingRoutes = this.intAirAct.DevicesSupportingRoute(Routes.SetOrientationRoute);
            foreach (IADevice iaDevice in devicesSupportingRoutes)
            {
                this.intAirAct.SendRequest(request, iaDevice, delegate(IAResponse response, Exception exception)
                {
                    if (exception != null)
                    {
                        failure(exception);
                        return;
                    }
                    else
                    {
                        success();
                    }
                });

                break;
            }
        }
コード例 #2
0
        public void SetOrientationTest()
        {
            Setup();

            // Set up a device
            PairableDevice device = new PairableDevice
            {
                Identifier = "myPad",
                Orientation = 20.0
            };
            Server.Locator.Devices.Add(device);

            Server.Start();
            Client.Start();
            WaitForConnections();

            // Build a request to set the device's orientation
            IARequest request = new IARequest(Routes.SetOrientationRoute);
            request.Parameters["identifier"] = "myPad";
            double newOrientation = 240.0;
            request.SetBodyWithString(newOrientation.ToString());

            // Send the request, and test
            Client.SendRequest(request, Server.IntAirAct.OwnDevice, delegate(IAResponse response, Exception exception)
            {
                Assert.AreEqual(240.0, device.Orientation.Value, 0.01);
            });

            Teardown();
        }