リポジトリ
使用例
using Cysharp.Threading.Tasks;
using Kogane;
public static class InternetChecker
{
private static readonly string[] ADDRESSES =
{
"8.8.8.8",
"8.8.4.4",
"4.2.2.2",
"4.2.2.3",
"4.2.2.4",
};
public static async UniTask<bool> IsOnlineAsync( float timeoutSeconds )
{
foreach ( var address in ADDRESSES )
{
var result = await PingUtils.SendAsync( address, timeoutSeconds );
if ( result.IsSuccess ) return true;
}
return false;
}
}
using Cysharp.Threading.Tasks;
using UnityEngine;
public class Example : MonoBehaviour
{
private async UniTaskVoid Start()
{
Debug.Log( await InternetChecker.IsOnlineAsync( 5 ) );
}
}
依存しているパッケージ