예제 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 form = new Form1();

            IAIntAirAct intAirAct = IAIntAirAct.New();

            intAirAct.Route(new IARoute("PUT", "/image"), delegate(IARequest req, IAResponse res)
            {
                logger.TraceEvent(TraceEventType.Information, 0, "Received request on {0}", req.Route);

                String url = req.BodyAsString();
                form.BeginInvoke((Action) delegate()
                {
                    form.LoadImageFromURL(url);
                });
            });

            intAirAct.Start();

            Application.Run(form);

            intAirAct.Stop();
        }
예제 #2
0
        public void Start()
        {
            personManager.StartPersonManager();
            deviceManager.StartDeviceManager();
            intAirAct.Start();

            gestureController.GestureRecognized += pairingRecognizer.PersonPairAttempt;
            communicationManager = new CommunicationManager(intAirAct, pairingRecognizer, locator, personManager);
        }
예제 #3
0
        public void TestMethod1()
        {
            ia = IAIntAirAct.New();
            ia.Start();
            ia.Stop();

            mse = new MSEKinectManager();

            //Setup();
            //Teardown();
        }
        public void SuccessfulPairingTest()
        {
            Setup();

            // Setup the 'became paired' route on the client.
            Client.Route(Routes.BecomePairedRoute, delegate(IARequest request, IAResponse response)
            {
                // In response to receiving 'became paired', we test some properties on the server

                // Find the mock pairable person we created, test their pairing state
                PairablePerson person = (PairablePerson)Server.Locator.Persons.Find(x => x.Identifier.Equals("Bob"));
                Assert.AreEqual(PairingState.Paired, person.PairingState);

                // Find the Client's IADevice on the server, test its pariing state
                PairableDevice device = (PairableDevice)Server.Locator.Devices.Find(x => x.Identifier.Equals(Client.OwnDevice.Name));
                Assert.AreEqual(PairingState.Paired, device.PairingState);

                // Test that the two were paired with each other
                Assert.AreEqual(person.HeldDeviceIdentifier, device.Identifier);
                Assert.AreEqual(device.HeldByPersonIdentifier, person.Identifier);

                doneWaitingForResponse = true;
            });

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

            // Create a person on the server, who is attempting to pair their device
            // NB: Setting PairingAttempt on a person begins a 3 second timer, after which it resets to NotPaired
            // The test should always complete before then, though
            Server.Locator.Persons.Add(new PairablePerson()
            {
                Identifier   = "Bob",
                Location     = new System.Windows.Point(1, 1),
                PairingState = PairingState.PairingAttempt
            });

            // Notify the server that the client wants to be paired
            Client.SendRequest(new IARequest(Routes.RequestPairingRoute), Server.IntAirAct.OwnDevice);

            WaitForResponse();
            Teardown();
        }
예제 #5
0
        static void Main(string[] args)
        {
            Program  p        = new Program();
            AmazonS3 s3Client = Program.GetS3Client();
            //Program.CreateNewFolder(s3Client, Program.BUCKET_NAME, "first folder");
            //Program.CreateBucket(s3Client);

            IAIntAirAct intAirAct = IAIntAirAct.New();

            IARoute imageRoute           = IARoute.Get("/SKA/image/{slicenumber}");
            IARoute imageRouteParameters = IARoute.Get("/SKA/image/{slicenumber}/{cmap}/{clipping}");
            IARoute numberOfSlicesRoute  = IARoute.Get("/SKA/numberOfSlices/{cmap}/{clipping}");


            intAirAct.Route(numberOfSlicesRoute, delegate(IARequest request, IAResponse response)
            {
                try
                {
                    string cmap     = request.Parameters["cmap"];
                    string clipping = request.Parameters["clipping"];
                    Program.SliceNumbers(s3Client, cmap, clipping);
                    response.SetBodyWithString(Program.SliceNumbers(s3Client, cmap, clipping));
                }
                catch
                {
                    response.SetBodyWithString("0");
                }
            });

            intAirAct.Route(imageRouteParameters, delegate(IARequest request, IAResponse response)
            {
                try
                {
                    int sliceNumber = Convert.ToInt32(request.Parameters["slicenumber"]);
                    string cmap     = request.Parameters["cmap"];
                    string clipping = request.Parameters["clipping"];

                    byte[] data = Program.GetImage(sliceNumber, cmap, clipping);

                    if (Program.imgfound == false)
                    {
                        response.StatusCode = 404;
                        Program.imgfound    = true;
                    }
                    else
                    {
                        response.Body        = data;
                        response.ContentType = "image/jpeg";
                    }
                }
                catch
                {
                    response.StatusCode = 404;
                }
            });

            intAirAct.Port = 12350;
            intAirAct.Start();

            Console.WriteLine("");
            Console.WriteLine(WebServer.GetExternalIP() + "Port " + intAirAct.Port.ToString());
            Console.WriteLine("\nA simple webserver. Press any key to quit.");
            Console.ReadKey();
        }
        public void SuccessfulPairingTest()
        {
            Setup();

            // We would like to be able to test the round trip communication, sending 'request pairing' on the client to the server, to sending
            // 'become paired' from server to client.
            // But internally, tinyIOC registers things by type, so only the first instance of intairact's server adapter gets retrieved.
            // All routes are handled by the same IAA instance, which is obviously a problem when we have two in the system that we would like to have talk to each other.

            // So, at present this part of the test cannot work
            //Client.Route(Routes.BecomePairedRoute, delegate(IARequest request, IAResponse response)
            //{
            //    doneWaitingForResponse = true;
            //});

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

            // Create a person on the server, who is attempting to pair their device
            // NB: Setting PairingAttempt on a Person begins a 3 second timer, after which their pairing state resets to NotPaired
            // The test should always complete before then, but if mysterious failures start appearing, it could be time related
            Server.Locator.Persons.Add(new PairablePerson()
            {
                Identifier   = "Bob",
                Location     = new System.Windows.Point(1, 1),
                PairingState = PairingState.PairingAttempt
            });

            // Notify the server that the client wants to be paired
            IARequest pairingRequest = new IARequest(Routes.RequestPairingRoute);

            pairingRequest.Origin = Client.OwnDevice;
            pairingRequest.Parameters["identifier"] = Client.OwnDevice.Name;
            Client.SendRequest(pairingRequest, Server.IntAirAct.OwnDevice, delegate(IAResponse response, Exception exception)
            {
                if (exception != null)
                {
                    System.Diagnostics.Debug.WriteLine(exception.Message);
                    Assert.Fail();
                }

                // In response to the return of the request, we test some properties on the server

                // Find the mock pairable person we created, test their pairing state
                PairablePerson person = (PairablePerson)Server.Locator.Persons.Find(x => x.Identifier.Equals("Bob"));
                Assert.AreEqual(PairingState.Paired, person.PairingState);

                // Find the Client's IADevice on the server, test its pariing state
                PairableDevice device = (PairableDevice)Server.Locator.Devices.Find(x => x.Identifier.Equals(Client.OwnDevice.Name));
                Assert.AreEqual(PairingState.Paired, device.PairingState);

                // Test that the two were paired with each other
                Assert.AreEqual(person.HeldDeviceIdentifier, device.Identifier);
                Assert.AreEqual(device.HeldByPersonIdentifier, person.Identifier);

                doneWaitingForResponse = true;
            });

            WaitForResponse();
            Teardown();
        }