コード例 #1
0
    void Start()
    {
        if (internetReachabilityVerifier == null)
        {
            internetReachabilityVerifier = (InternetReachabilityVerifier)GameObject.FindObjectOfType(typeof(InternetReachabilityVerifier));
            if (internetReachabilityVerifier == null)
            {
                Debug.LogError("No Internet Reachability Verifier set up for the IRVExample and none can be found in the scene!", this);
                return;
            }
        }

        internetReachabilityVerifier.statusChangedDelegate += netStatusChanged;

        appendLog("IRVExample log:\n");
        appendLog("(Initially selected method: " + internetReachabilityVerifier.captivePortalDetectionMethod + ")");

        if (internetReachabilityVerifier.captivePortalDetectionMethod ==
            InternetReachabilityVerifier.CaptivePortalDetectionMethod.DefaultByPlatform)
        {
            // InternetReachabilityVerifier Start() has not been run yet,
            // which will determine the actual method. We want to show that
            // in the log and OnGUI here, so this flag indicates it's pending.
            logChosenDefaultByPlatformMethodPending = true;
        }

        selectedMethod = (int)internetReachabilityVerifier.captivePortalDetectionMethod;
        int methodCount = 14;

        methodNames = new string[methodCount];
        for (int a = 0; a < methodCount; ++a)
        {
            methodNames[a] = ((InternetReachabilityVerifier.CaptivePortalDetectionMethod)a).ToString();
        }
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        InternetReachabilityVerifier irv = (InternetReachabilityVerifier)target;

        UnityEditor.MessageType mt = MessageType.Warning;

        serializedObject.Update();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("captivePortalDetectionMethod"), true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("customMethodURL"), true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("customMethodExpectedData"), true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("customMethodWithCacheBuster"), true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("dontDestroyOnLoad"), true);

        mt = MessageType.None;
        if (irv.defaultCheckPeriod < 1 / 5.0f)
        {
            mt = MessageType.Error;
        }
        else if (irv.defaultCheckPeriod < 1)
        {
            mt = MessageType.Warning;
        }
        if (mt != MessageType.None)
        {
            EditorGUILayout.HelpBox("Suggested minimum for Default Check Period is 1 second.\nUsing too small value can degrade performance.", mt);
        }
        EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultCheckPeriod"), true);

        mt = MessageType.None;
        if (irv.errorRetryDelay < 1 / 2.0f)
        {
            mt = MessageType.Error;
        }
        else if (irv.errorRetryDelay < 3)
        {
            mt = MessageType.Warning;
        }
        if (mt != MessageType.None)
        {
            EditorGUILayout.HelpBox("Suggested minimum for Error Retry Delay is 3 seconds.\nUsing too small value can degrade performance.", mt);
        }
        EditorGUILayout.PropertyField(serializedObject.FindProperty("errorRetryDelay"), true);

        mt = MessageType.None;
        if (irv.mismatchRetryDelay < 1 / 3.0f)
        {
            mt = MessageType.Error;
        }
        else if (irv.mismatchRetryDelay < 2)
        {
            mt = MessageType.Warning;
        }
        if (mt != MessageType.None)
        {
            EditorGUILayout.HelpBox("Suggested minimum for Mismatch Retry Delay is 2 seconds.\nUsing too small value can degrade performance.", mt);
        }
        EditorGUILayout.PropertyField(serializedObject.FindProperty("mismatchRetryDelay"), true);

        serializedObject.ApplyModifiedProperties();
    }
コード例 #3
0
    private IEnumerator Start()
    {
        _internetReachabilityVerifier = GetComponent <InternetReachabilityVerifier>();
        _internetReachabilityVerifier.statusChangedDelegate += UpdateNetworkStatusBox;

        yield return(new WaitForEndOfFrame());

        CheckBoxes();
    }
コード例 #4
0
 private void Awake()
 {
     if (InternetReachabilityVerifier._instance != null)
     {
         DestroyImmediate(base.gameObject);
         return;
     }
     InternetReachabilityVerifier._instance = this;
     DontDestroyOnLoad(base.gameObject);
 }
コード例 #5
0
    void Start()
    {
        // Setup status change listening with a delegate. (recommended way)
        internetReachabilityVerifier = GetComponent <InternetReachabilityVerifier>();
        internetReachabilityVerifier.statusChangedDelegate += netStatusChanged;

        // Set up additional optional way - the coroutine waits until network is availble.
        StartCoroutine(waitForNetwork());

        // Note: See the CustomIRVExample for more info about how to
        //       verify Internet access using your self-hosted URL.
    }
コード例 #6
0
        void Start()
        {
            irv = GetComponent <InternetReachabilityVerifier>();
            irv.customMethodVerifierDelegate = verifyNetCheckData;
            irv.statusChangedDelegate       += netStatusChanged;

            appendLog("CustomIRVExample log:\n");
            appendLog("Selected method: " + irv.captivePortalDetectionMethod);
            appendLog("Custom Method URL: " + irv.customMethodURL);
            appendLog("Custom Method Expected Data: " + irv.customMethodExpectedData);
            if (irv.customMethodVerifierDelegate != null)
            {
                appendLog("Using custom method verifier delegate.");
            }
            if (irv.customMethodURL.Contains("strobotnik.com"))
            {
                appendLog("*** IMPORTANT WARNING: ***\nYou're using the default TEST value for Custom Method URL specified in example scene.\nTHAT SERVER HAS NO GUARANTEE OF BEING UP AND RUNNING.\nPlease use your own custom server and URL!\n*****\n", true);
            }
        }
コード例 #7
0
    void Start()
    {
        irv = GetComponent <InternetReachabilityVerifier>();
        irv.customMethodVerifierDelegate = verifyNetCheckData;
        irv.statusChangedDelegate       += netStatusChanged;

        appendLog("CustomIRVExample log:\n");
        appendLog("Selected method: " + irv.captivePortalDetectionMethod);
        appendLog("Custom Method URL: " + irv.customMethodURL);
        appendLog("Custom Method Expected Data: " + irv.customMethodExpectedData);
        if (irv.customMethodVerifierDelegate != null)
        {
            appendLog("Using custom method verifier delegate.");
        }
        if (irv.customMethodURL.Contains("strobotnik.com"))
        {
            appendLog("WARNING - You're using the default value for Custom Method URL specified in example scene. It has no guarantee of being up and running. Please use your own custom URL.\n");
        }
    }
コード例 #8
0
 static InternetReachabilityVerifier()
 {
     InternetReachabilityVerifier._instance = null;
     //InternetReachabilityVerifier.methodGoogle204Supported = new RuntimePlatform[] { typeof(< PrivateImplementationDetails >).GetField("$field-A521C39CEF3283C4ED1AFD0A913B091FAFDDFD6D").FieldHandle };
 }
コード例 #9
0
 public static bool IsReachable(this IRVerifier @this)
 => @this.status == IRVerifier.Status.NetVerified ||
 @this.status == IRVerifier.Status.PendingVerification;
コード例 #10
0
 public static bool IsNetVerified(this IRVerifier @this)
 => @this.status == IRVerifier.Status.NetVerified;