コード例 #1
0
    // These are just thin wrappers over the SDK to show how to use them:
    // Call once, or when the carrier changes. May throw DistributedMatchEngine.HttpException.
    public async Task <bool> Register()
    {
        // If MEX is reachable on your SIM card:
        string aCarrierName = GetCarrierName();
        string eCarrierName;

        if (me.useOnlyWifi)
        {
            eCarrierName = carrierName;
        }
        else
        {
            if (aCarrierName == null)
            {
                Debug.Log("Missing CarrierName for RegisterClient.");
                return(false);
            }
            eCarrierName = aCarrierName;
        }

        RegisterClientRequest req = me.CreateRegisterClientRequest(eCarrierName, orgName, appName, appVers, authToken, cellID, uniqueIDType, uniqueID, tags);

        Debug.Log("CarrierName: " + req.carrier_name);
        Debug.Log("orgName: " + req.org_name);
        Debug.Log("AppName: " + req.app_name);
        Debug.Log("AppVers: " + req.app_vers);

        RegisterClientReply reply = await me.RegisterClient(req);

        return(reply.status == ReplyStatus.RS_SUCCESS);
    }
コード例 #2
0
    async Task <bool> DoRegisterClient()
    {
        bool                ok    = false;
        MatchingEngine      dme   = mexSample.dme;
        RegisterClientReply reply = null;

        try
        {
            var registerClientRequest = dme.CreateRegisterClientRequest(
                mexSample.carrierName,
                mexSample.orgName,
                mexSample.appName,
                mexSample.appVers,
                mexSample.authToken);

            reply = await dme.RegisterClient(mexSample.host, mexSample.port, registerClientRequest);

            // the dme object stores the session tokens, so the only thing to do here is
            // inspect parts of the JSON registration status and retry:
            if (reply.status != ReplyStatus.RS_SUCCESS)
            {
                statusContainer.Post("RegisterClient did not succeed!");
            }
            else
            {
                ok = true;
            }
        }
        catch (System.Net.WebException we)
        {
            Console.WriteLine(we.StackTrace);
            statusContainer.Post(we.Source + ", WebException: " + we.Message);
            statusContainer.Post(we.StackTrace);
        }
        finally
        {
            if (reply != null)
            {
                statusContainer.Post(
                    "RegisterClient Button results:" +
                    " Status: " + reply.status +
                    " SessionCookie: " + reply.session_cookie +
                    " TokenServerURI: " + reply.token_server_uri
                    );
            }
        }
        return(ok);
    }
コード例 #3
0
    // These are just thin wrappers over the SDK to show how to use them:
    // Call once, or when the carrier changes. May throw DistributedMatchEngine.HttpException.
    public async Task <bool> Register()
    {
        // If MEX is reachable on your SIM card:
        string aCarrierName = GetCarrierName();
        string eCarrierName;

        if (useDemo)
        {
            eCarrierName = carrierName;
        }
        else
        {
            if (aCarrierName == null)
            {
                Debug.Log("Missing CarrierName for RegisterClient.");
                return(false);
            }
            eCarrierName = aCarrierName;
        }

        RegisterClientRequest req = me.CreateRegisterClientRequest(eCarrierName, devName, appName, appVers, "" /* developer specific string blob */);

        Debug.Log("CarrierName: " + req.carrier_name);
        Debug.Log("DevName: " + req.dev_name);
        Debug.Log("AppName: " + req.app_name);
        Debug.Log("AppVers: " + req.app_vers);

        RegisterClientReply reply;

        if (useDemo)
        {
            reply = await me.RegisterClient(dmeHost, dmePort, req);
        }
        else
        {
            reply = await me.RegisterClient(req);
        }

        return(reply.status == ReplyStatus.RS_SUCCESS);
    }