Show / Hide Table of Contents

    Class NetworkServices

    Provides cross-platform interface to check network connectivity status.

    Inheritance
    System.Object
    NetworkServices
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ToString()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: VoxelBusters.EssentialKit
    Assembly: cs.temp.dll.dll
    Syntax
    public static class NetworkServices
    Examples

    The following example illustrates how to use network service related events.

    using UnityEngine;
    using System.Collections;
    using VoxelBusters.EssentialKit;
    
    public class ExampleClass : MonoBehaviour 
    {
        private void OnEnable()
        {
            // registering for event
            NetworkServices.OnInternetConnectivityChange    += OnInternetConnectivityChange;
            NetworkServices.OnHostReachabilityChange        += OnHostReachabilityChange;
        }
    
        private void OnDisable()
        {
            // unregistering event
            NetworkServices.OnInternetConnectivityChange    -= OnInternetConnectivityChange;
            NetworkServices.OnHostReachabilityChange        -= OnHostReachabilityChange;
        }
    
        private void OnInternetConnectivityChange(NetworkServicesInternetConnectivityStatus data)
        {
            if (data.IsConnected)
            {
                // notify user that he/she is online
            }
            else
            {
                // notify user that he/she is offline
            }
        }
    
        private void OnHostReachabilityChange(NetworkServicesHostReachabilityStatus data)
        {
            Debug.Log("Host connectivity status: " + data.IsReachable);
        }
    }

    Properties

    IsHostReachable

    A boolean value that is used to determine whether host is reachable or not.

    Declaration
    public static bool IsHostReachable { get; }
    Property Value
    Type Description
    System.Boolean

    true if is host reachable; otherwise, false.

    IsInternetActive

    A boolean value that is used to determine internet connectivity status.

    Declaration
    public static bool IsInternetActive { get; }
    Property Value
    Type Description
    System.Boolean

    true if connected to network; otherwise, false.

    IsNotifierActive

    A boolean value that is used to determine whether notifier is running or not.

    Declaration
    public static bool IsNotifierActive { get; }
    Property Value
    Type Description
    System.Boolean

    true if notifier is active; otherwise, false.

    UnitySettings

    Declaration
    public static NetworkServicesUnitySettings UnitySettings { get; }
    Property Value
    Type Description
    NetworkServicesUnitySettings

    Methods

    IsAvailable()

    Declaration
    public static bool IsAvailable()
    Returns
    Type Description
    System.Boolean

    StartNotifier()

    Starts the notifier.

    Declaration
    public static void StartNotifier()

    StopNotifier()

    Stops the notifier.

    Declaration
    public static void StopNotifier()

    Events

    OnHostReachabilityChange

    Event that will be called whenever host reachability state changes.

    Declaration
    public static event Callback<NetworkServicesHostReachabilityStatusChangeResult> OnHostReachabilityChange
    Event Type
    Type Description
    Callback<NetworkServicesHostReachabilityStatusChangeResult>

    OnInternetConnectivityChange

    Event that will be called whenever network state changes.

    Declaration
    public static event Callback<NetworkServicesInternetConnectivityStatusChangeResult> OnInternetConnectivityChange
    Event Type
    Type Description
    Callback<NetworkServicesInternetConnectivityStatusChangeResult>
    Back to top Cross Platform Native Plugins 2.0 : Essential Kit from Voxel Busters