Space Ad Mobile 9.5.1
Space Ad Mobile makes ads easy to add into your mobile game: one unified workflow for LevelPlay, AdMob, Yandex.Ads across banners, interstitials and rewarded.
Loading...
Searching...
No Matches
InternetConnectionChecker.cs
1using System.Net;
2using UnityEngine;
3
4namespace SCG.SpaceAdMobile
5{
11 public enum CheckInternetConnectionType : byte
12 {
18 [Tooltip("Uses Unity's Application.internetReachability signal.")]
19 Simple = 0,
25 [Tooltip("Performs an actual network call (HTTP HEAD) to a known endpoint.")]
27 }
28
35 {
41 }
42
49 {
54 public bool CheckInternetConnection() => Application.internetReachability != NetworkReachability.NotReachable;
55 }
56
63 {
68 public string RequestUrl { get; set; } = "http://unity.com";
69
76 {
77 const string requestMethod = "HEAD";
78 try
79 {
80 var request = (HttpWebRequest)WebRequest.Create(RequestUrl);
81 request.Method = requestMethod;
82 using var response = (HttpWebResponse)request.GetResponse();
83 return response.StatusCode == HttpStatusCode.OK;
84 }
85 catch
86 {
87 return false;
88 }
89 }
90 }
91}
string RequestUrl
Endpoint to probe with an HTTP HEAD request. Use a lightweight, highly available URL; defaults to "ht...
bool CheckInternetConnection()
Issues an HTTP HEAD request to RequestUrl. Returns true only if the server responds with 200 OK; any ...
Network I/O–based checker issuing an HTTP HEAD request to a configurable URL. Provides higher confide...
bool CheckInternetConnection()
Returns true when Unity reports the internet is reachable; false otherwise. This is a signal-level ch...
Lightweight checker based on Application.internetReachability. Optimized for mobile devices where it ...
bool CheckInternetConnection()
Checks network reachability/availability. Should return true when online and false when offline or un...
Contract for pluggable internet connectivity checkers. Implementations should return true when the ne...
CheckInternetConnectionType
Defines the strategy used to verify internet connectivity. Choose between a fast platform signal chec...
@ Request
Performs an actual network call (HTTP HEAD) to a known endpoint. More accurate but slower and can be ...
@ Simple
Uses Unity's Application.internetReachability signal. Fast and battery-friendly on mobile devices; re...