Events

Various events are raised during the lifetime of an internet check. Events are very useful become they allow you to implement various different logics based on your requirements, when it comes to network status detection. You can listen to them from as many scripts as you want.

Make sure to not listen to events twice from the same script, or keep listening to them when not wanted.

OnCheckStarted

This event is raised as soon as an internet check is started. It will be raised for every internet check, if you have started a continuous check.

You can listen/stop listening to this event this way:

...

// Start listening
EazyNetChecker.OnCheckStarted += OnNetCheckStarted;

...

// Stop listening when you don't need it
EazyNetChecker.OnCheckStarted -= OnNetCheckStarted;

...

private void OnNetCheckStarted() 
{ 
    Debug.Log("Internet check just started"); 
}

OnCheckFinished

This event is raised as soon as an internet check is finished. It will be raised for every internet check, if you have started a continuous check.

You can listen/stop listening to this event this way:

...

// Start listening
EazyNetChecker.OnCheckFinished += OnNetCheckFinished;

...

// Stop listening when you don't need it
EazyNetChecker.OnCheckFinished -= OnNetCheckFinished;

...

private void OnNetCheckFinished() 
{ 
    Debug.Log("Internet check just finished with status " + EazyNetChecker.Status); 
}

OnConnectionStatusChanged

This event is raised as soon as an internet check is finished and a different connection status is detected. You can use this event to act accordingly if the connection status changes and you want to handle connection-specific logic.

You can listen/stop listening to this event this way:

...

// Start listening
EazyNetChecker.OnConnectionStatusChanged += OnNetConnectionStatusChanged;

...

// Stop listening when you don't need it
EazyNetChecker.OnConnectionStatusChanged -= OnNetConnectionStatusChanged;

...

private void OnNetConnectionStatusChanged() 
{ 
    Debug.Log("Internet status changed to " + EazyNetChecker.Status); 
}

OnCheckTimeout

This event is raised when an internet check times out. An internet check will time out if it is not able to detect the internet connection status within the specified timeout period.

You can listen/stop listening to this event this way:

...

// Start listening
EazyNetChecker.OnCheckTimeout += OnNetCheckTimeout;

...

// Stop listening when you don't need it
EazyNetChecker.OnCheckTimeout -= OnNetCheckTimeout;

...

private void OnNetCheckTimeout() 
{ 
    Debug.Log("Check timed out! Unable to determine internet connection"); 
}

Last updated