Essential Kit
Loading...
Searching...
No Matches
NetworkServices

Provides cross-platform interface to check network connectivity status. More...

Static Public Member Functions

static void StartNotifier ()
 Starts the notifier.
 
static void StopNotifier ()
 Stops the notifier.
 
Advanced Usage
static void Initialize (NetworkServicesUnitySettings settings)
 Initialize the NetworkServices module with the given settings. This call is optional and only need to be called if you have custom settings to initialize this feature.
 

Properties

static bool IsInternetActive [get]
 A boolean value that is used to determine internet connectivity status.
 
static bool IsHostReachable [get]
 A boolean value that is used to determine whether host is reachable or not.
 
static bool IsNotifierActive [get]
 A boolean value that is used to determine whether notifier is running or not.
 

Events

static Callback< NetworkServicesInternetConnectivityStatusChangeResultOnInternetConnectivityChange
 Event that will be called whenever network state changes.
 
static Callback< NetworkServicesHostReachabilityStatusChangeResultOnHostReachabilityChange
 Event that will be called whenever host reachability state changes.
 

Detailed Description

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

using UnityEngine;
using System.Collections;
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);
}
}
Namespace for essential kit features. You need to import this namespace along with VoxelBusters....
Definition AddressBook.cs:8

Member Function Documentation

◆ Initialize()

static void Initialize ( NetworkServicesUnitySettings settings)
static
Parameters
settingsThe settings to be used for initialization.

The settings configure the behavior of the NetworkServices module.

References NetworkServices.IsHostReachable, NetworkServices.IsInternetActive, NetworkServices.OnHostReachabilityChange, NetworkServices.OnInternetConnectivityChange, and NetworkServices.StartNotifier().

Property Documentation

◆ IsInternetActive

bool IsInternetActive
staticget

true if connected to network; otherwise, false.

Referenced by NetworkServices.Initialize().

◆ IsHostReachable

bool IsHostReachable
staticget

true if is host reachable; otherwise, false.

Referenced by NetworkServices.Initialize().

◆ IsNotifierActive

bool IsNotifierActive
staticget

true if notifier is active; otherwise, false.

Referenced by NetworkServices.StartNotifier(), and NetworkServices.StopNotifier().