public async void MobiledgeXAPICalls()
        {
            gameManager.clog("RegisterClient NOT IMPLEMENTED");
            return;

            gameManager.clog("FindCloudlet NOT IMPLEMENTED");
            return;

            gameManager.clog("GetAppPort NOT IMPLEMENTED");
            return;

            gameManager.clog("GetUrl NOT IMPLEMENTED");
            return;

            // NetTest
            netTest = new NetTest(integration.matchingEngine);
            foreach (AppPort ap in integration.FindCloudletReply.ports)
            {
                gameManager.clog("Port: proto: " + ap.proto + ", prefix: " + ap.fqdn_prefix + ", path_prefix: " + ap.path_prefix + ", port: " + ap.public_port);

                NetTest.Site site;
                // We're looking for one of the TCP app ports:
                if (ap.proto == LProto.L_PROTO_TCP)
                {
                    // Add to test targets.
                    if (ap.path_prefix == "")
                    {
                        site = new NetTest.Site
                        {
                            host = integration.GetHost(ap),
                            port = integration.GetPort(ap)
                        };
                        site.testType = NetTest.TestType.CONNECT;
                    }
                    else
                    {
                        site = new NetTest.Site
                        {
                            L7Path = integration.GetUrl("", ap)
                        };
                        site.testType = NetTest.TestType.CONNECT;
                    }
                    if (useAltServer)
                    {
                        site.host = host;
                    }
                    l7Path = site.L7Path;
                    netTest.sites.Enqueue(site);
                }
            }
            netTest.doTest(true);
        }
Exemple #2
0
        public async void MobiledgeXAPICalls()
        {
            integration.UseWifiOnly(true);
            // RegisterAndFindCloudlet and VerifyLocation:
            FindCloudletReply findCloudletReply;

            try
            {
                gameManager.uiConsole.text = "Registering to DME: ";
                bool registeredAndFoundCloudlet = await integration.RegisterAndFindCloudlet();

                if (!registeredAndFoundCloudlet)
                {
                    gameManager.clog("Unable to register and find cloudlet");
                    return;
                }
                stopWatch.Start();

                findCloudletReply = integration.FindCloudletReply;
                gameManager.clog("FindCloudletReply: status: " + findCloudletReply.status + ", fqdn: " + findCloudletReply.fqdn);

                // This might be inside a thread update loop. Re-register client and check periodically.
                // VerifyLocation will fail if verification is unavailable at the carrier.
                bool verifiedLocation = await integration.VerifyLocation();

                // Decide what to do with location status.
                gameManager.clog("VerifiedLocation: " + verifiedLocation);
            }
            catch (RegisterClientException rce)
            {
                gameManager.clog("RegisterClientException: " + rce.Message + ". Make sure OrgName, AppName, and AppVers are correct.");
                return;
            }
            catch (FindCloudletException fce)
            {
                gameManager.clog("FindCloudletException: " + fce.Message + ". Make sure you have an app instance deployed to your region and carrier network");
                return;
            }
            catch (DmeDnsException de)
            {
                // This app should fallback to public cloud, as the DME doesn't exist for your
                // SIM card + carrier.
                gameManager.clog("Cannot register to DME host: " + de.Message + ", Stack: " + de.StackTrace);
                if (de.InnerException != null)
                {
                    gameManager.clog("Original Exception: " + de.InnerException.Message);
                }
                // Handle fallback to public cloud application server.
                return;
            }
            catch (Exception e)
            {
                gameManager.clog("Unexpected Exception: " + e.StackTrace);
                return;
            }

            // GetAppPort
            AppPort appPort;

            try
            {
                appPort = integration.GetAppPort(LProto.L_PROTO_TCP);
            }
            catch (AppPortException ape)
            {
                gameManager.clog("Unabled to get AppPort. AppPortException: " + ape.Message);
                return;
            }
            if (appPort == null)
            {
                gameManager.clog("GetAppPort returned null");
                return;
            }

            // GetUrl
            try
            {
                edgeCloudletStr = integration.GetUrl("ws");
                gameManager.clog("Found Cloudlet from DME result: [" + edgeCloudletStr + "]");
            }
            catch (GetConnectionException gce)
            {
                gameManager.clog("Unabled to get url. GetConnectionException " + gce.Message);
                return;
            }

            // NetTest
            netTest = new NetTest(integration.matchingEngine);
            foreach (AppPort ap in findCloudletReply.ports)
            {
                gameManager.clog("Port: proto: " + ap.proto + ", prefix: " + ap.fqdn_prefix + ", path_prefix: " + ap.path_prefix + ", port: " + ap.public_port);

                NetTest.Site site;
                // We're looking for one of the TCP app ports:
                if (ap.proto == LProto.L_PROTO_TCP)
                {
                    // Add to test targets.
                    if (ap.path_prefix == "")
                    {
                        site = new NetTest.Site
                        {
                            host = integration.GetHost(ap),
                            port = integration.GetPort(ap)
                        };
                        site.testType = NetTest.TestType.CONNECT;
                    }
                    else
                    {
                        site = new NetTest.Site
                        {
                            L7Path = integration.GetUrl("", ap)
                        };
                        site.testType = NetTest.TestType.CONNECT;
                    }
                    if (useAltServer)
                    {
                        site.host = host;
                    }
                    l7Path = site.L7Path;
                    netTest.sites.Enqueue(site);
                }
            }
            netTest.doTest(true);
        }
Exemple #3
0
        // Start() is a time to do this, but can change if the device moves to a new location.
        // The return string is just an example. Your server protocol and connection strings
        // will determine the correct connection parameters.
        async Task <String> RegisterAndFindCloudlet()
        {
            // For Demo App purposes, it's the TCP app port. Your app may point somewhere else:
            NetTest.Site site;

            string aCarrierName = integration.GetCarrierName();

            clog("aCarrierName: " + aCarrierName);


            clog("Calling DME to register client...");
            bool registered = false;

            registered = await integration.Register();

            if (!registered)
            {
                clog("Exceptions, or app not found. Not Registered!");
                return(null);
            }
            else
            {
                FindCloudletReply reply;
                clog("Finding Cloudlet...");
                reply = await integration.FindCloudlet();


                // Handle reply status:
                bool found = false;
                if (reply == null)
                {
                    clog("FindCloudlet call failed.");
                    return("");
                }

                switch (reply.status)
                {
                case FindCloudletReply.FindStatus.FIND_UNKNOWN:
                    clog("FindCloudlet status unknown. No edge cloudlets.");
                    break;

                case FindCloudletReply.FindStatus.FIND_NOTFOUND:
                    clog("FindCloudlet Found no edge cloudlets in range.");
                    break;

                case FindCloudletReply.FindStatus.FIND_FOUND:
                    found = true;
                    break;
                }

                if (found)
                {
                    // Edge cloudlets found!
                    clog("Edge cloudlets found!");

                    // Where is this app specific edge enabled cloud server:
                    clog("GPS location: longitude: " + reply.cloudlet_location.longitude + ", latitude: " + reply.cloudlet_location.latitude);

                    // Where is the URI for this app specific edge enabled cloud server:
                    clog("fqdn: " + reply.fqdn);
                    // AppPorts?
                    clog("On ports: ");

                    foreach (AppPort ap in reply.ports)
                    {
                        clog("Port: proto: " + ap.proto + ", prefix: " +
                             ap.fqdn_prefix + ", path_prefix: " + ap.path_prefix + ", port: " +
                             ap.public_port);

                        // We're looking for one of the TCP app ports:
                        if (ap.proto == LProto.L_PROTO_TCP)
                        {
                            // Add to test targets.
                            if (ap.path_prefix == "")
                            {
                                site = new NetTest.Site {
                                    host = ap.fqdn_prefix + reply.fqdn,
                                    port = ap.public_port
                                };
                                site.testType = NetTest.TestType.CONNECT;
                            }
                            else
                            {
                                site = new NetTest.Site {
                                    L7Path = ap.fqdn_prefix + reply.fqdn + ":" + ap.public_port + ap.path_prefix
                                };
                                site.testType = NetTest.TestType.CONNECT;
                            }
                            if (useAltServer)
                            {
                                site.host = host;
                            }
                            port      = site.port;
                            l7Path    = site.L7Path;
                            site.host = "mextest-app-cluster.frankfurt-main.tdg.mobiledgex.net";
                            integration.netTest.sites.Enqueue(site);
                        }
                    }
                    integration.netTest.doTest(true);
                }
            }

            // The WebSocket URI:
            return(host + ":" + port);
        }