Exemplo n.º 1
0
        public void addNetworkMonitor()
        {
            string httpUrl = "https://www.developer.huawei.com";
            // 1. Create a networkMeasure for this special network request
            NetworkMeasure networkMeasure = APMS.getInstance().createNetworkMeasure(httpUrl, "GET");

            NetworkPropertyTest(networkMeasure);
            // 2. Add custom property for this network measure
            networkMeasure.putProperty("activityName", "MainActivity");
            // 3. start this network measure
            Debug.Log("networkMeasure start");
            networkMeasure.start();

            networkMeasure.setBytesSent(1024);
            networkMeasure.setContentType("UTF-8");

            Debug.Log("start the fake url request process");
            for (int i = 0; i < 1024; i++)
            {
            }

            int bodysize = 1024;

            // 4. Set response body size for this network measure
            networkMeasure.setBytesReceived(bodysize);

            // 5. Set network response code for this network measure
            int responseCode = 400;

            networkMeasure.setStatusCode(responseCode);

            // 6. Stop this network measure
            networkMeasure.stop();
            Debug.Log("networkMeasure stop");
        }
Exemplo n.º 2
0
        public void NetworkPropertyTest(NetworkMeasure networkMeasure)
        {
            UnityEngine.Debug.Log("NetworkPropertyTest start");

            networkMeasure.putProperty("Unity", "unity.com");
            networkMeasure.putProperty("Group", "R&D");

            string value = networkMeasure.getProperty("Unity");

            Debug.Log("get prop name: Unity, value: " + value);

            networkMeasure.removeProperty("Unity");

            Map propertyMap = networkMeasure.getProperties();

            if (propertyMap != null)
            {
                UnityEngine.Debug.Log("NetworkPropertyTest success");
            }
        }