Cross Platform Native Plugins
A true cross platform tool for Unity which provides unique and unified way to access native functionality on mobile platforms.
Public Member Functions | Properties | Events | List of all members
NetworkConnectivity Class Reference

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

Public Member Functions

virtual void Initialise ()
 Initialises the component with the configuration values set in Network Connectivity Settings. More...
 
delegate void NetworkConnectivityChanged (bool _isConnected)
 Delegate that will be called whenever connectivity state changes. More...
 

Properties

bool IsConnected [get, protected set]
 A bool value that indicates connectivity status. More...
 

Events

static NetworkConnectivityChanged NetworkConnectivityChangedEvent
 Event that will be called whenever connectivity state changes. More...
 

Detailed Description

Provides cross-platform interface to check network connectivity status.

Member Function Documentation

virtual void Initialise ( )
virtual

Initialises the component with the configuration values set in Network Connectivity Settings.

Note
You need to call this method, to start checking if IP Address specified in the Network Connectivity Settings is reachable or not.
delegate void NetworkConnectivityChanged ( bool  _isConnected)

Delegate that will be called whenever connectivity state changes.

Parameters
_isConnectedtrue if connected to network; otherwise, false.

Property Documentation

bool IsConnected
getprotected set

A bool value that indicates connectivity status.

true if connected to network; otherwise, false.

Event Documentation

NetworkConnectivityChanged NetworkConnectivityChangedEvent
static

Event that will be called whenever connectivity state changes.

The following code example demonstrates how to use this event.

using System.Collections;
public class ExampleClass : MonoBehaviour
{
private void OnEnable ()
{
// Registering for event
NetworkConnectivity.NetworkConnectivityChangedEvent += OnNetworkConnectivityChanged;
}
private void OnDisable ()
{
// Unregistering event
NetworkConnectivity.NetworkConnectivityChangedEvent -= OnNetworkConnectivityChanged;
}
private void OnNetworkConnectivityChanged (bool _isConnected)
{
if (_isConnected)
{
// Handle when app goes online
}
else
{
// Handle when app goes offline
}
}
}