プラットフォーム | サポート状況 |
Windows (Standalone) | ✅ 対応しています。 |
Android | ✅ 対応しています。 |
iOS | ✅ 対応しています。 |
Unity Editor | ✅ 対応しています(Windows DLLを使用)。 |
Assets/└── Plugins/└── Unity_CLS/├── Unity_CLS.cs # C# 統一インターフェース層├── Android/│ └── libs/│ ├── all-dependencies-1.0.0-shaded.jar #Androidに必要なjava依存関係│ ├── network-diagnosis-release.aar #ネットワークプローブ依存関係│ ├── producer-release.aar #ログ報告依存関係│ └── unity-release.aar #unity連携依存関係├── Windows/│ └── cls_network_detect.dll #windowsネットワークプローブ+ログ報告動的ライブラリ└── iOS/├── UnityApi.h #iosと連携するためのブリッジコード├── UnityApi.m├── TencentCloudLogProducer.framework #cls ios sdkパッケージ├── FMDB.framework #cls ios sdkに必要な依存関係├── Protobuf.framework└── Reachability.framework
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application>タグに平文トラフィックサポート(HTTPプローブ用)を追加することをお勧めします:<application android:usesCleartextTraffic="true">
using System.Collections.Generic;using UnityEngine;using TencentCloudCLS;public class NetworkDiagnosisDemo : MonoBehaviour{void Start(){// 1. SDKを初期化します。Credential credential = new Credential();credential.endpoint = "ap-guangzhou.cls.tencentcs.com";credential.secretId = "お客様の SecretId";credential.secretKey = "お客様の SecretKey";credential.geoToken = "お客様の GeoToken";Unity_CLS.Initialize(credential);// 2. ユーザーカスタム拡張フィールドを設定します(任意)。Dictionary<string, string> userCustomField = new Dictionary<string, string>();userCustomField.Add("app_version", "1.0.0");userCustomField.Add("user_id", "12345");Unity_CLS.SetUserCustom(userCustomField);// 3. TCP Pingプローブを実行します。TcpPingRequest tcpRequest = new TcpPingRequest();tcpRequest.target = "www.baidu.com";tcpRequest.port = 80;tcpRequest.callback = (response) =>{Debug.Log("TCP Ping 結果: " + response);};Unity_CLS.TcpPing(tcpRequest);}}
Unity_CLS.Initialize(Credential credential)
フィールド | タイプ | 必須 | 説明 |
endpoint | string | はい | CLSサービスエンドポイント。例えば「ap-guangzhou.cls.tencentcs.com」です。 |
secretId | string | はい | |
secretKey | string | はい | |
topicId | string | いいえ | CLSログトピックID(geoTokenを使用する場合は省略可能) |
geoToken | string | いいえ |
Credential credential = new Credential();credential.endpoint = "ap-guangzhou.cls.tencentcs.com";credential.secretId = "お客様の SecretId";credential.secretKey = "お客様の SecretKey";credential.geoToken = "お客様の GeoToken";Unity_CLS.Initialize(credential);
Unity_CLS.SetUserCustom(Dictionary<string, string> userCustomField)
Dictionary<string, string> userCustomField = new Dictionary<string, string>();userCustomField.Add("app_version", "1.0.0");userCustomField.Add("user_id", "12345");userCustomField.Add("channel", "official");Unity_CLS.SetUserCustom(userCustomField);
Unity_CLS.TcpPing(TcpPingRequest request)
フィールド | タイプ | デフォルト値 | プラットフォーム対応 | 説明 |
target | string | "" | 全プラットフォーム | ターゲットホスト名またはIPアドレス |
port | int | -1 | 全プラットフォーム | ターゲットポート番号 |
count | int | 1 | 全プラットフォーム | プローブ回数 |
timeout | int | 1000 | 全プラットフォーム | タイムアウト時間(ミリ秒) |
size | int | 0 | Windows/Android | 送信データパケットサイズ(バイト)です。0はデータを送信しないことを表します。 |
payload | string | null | Windows/Android | ターゲットポートに送信するテストデータの内容 |
interval | int | 300 | Windows | プローブ間隔時間(ミリ秒) |
enableVerification | int | 1 | Windows | 接続検証を有効にするかどうか 1:有効 0:無効 |
prefer | int | 0 | Windows/iOS | IPバージョン優先設定 0:IPv4優先 1:IPv6優先 2:IPv4 only 3:IPv6 only |
netId | int | 0 | Windows | ネットワークカードID |
traceId | string | null | 全プラットフォーム | トレースID(null可、自動生成) |
src | string | null | Windows | ソース識別子 |
multiplePortsDetect | bool | true | Android | マルチポートプローブを実行するかどうか |
enableMultiplePortsDetect | bool | false | iOS | マルチポートプローブを有効にするかどうか |
detectCustomField | Dictionary | 空の辞書 | 全プラットフォーム | 検出拡張フィールド |
callback | callback_response | null | 全プラットフォーム | 結果コールバック関数 |
TcpPingRequest request = new TcpPingRequest();request.target = "www.baidu.com";request.port = 80;request.count = 3;request.timeout = 2000;request.detectCustomField = new Dictionary<string, string>(){{ "scene", "login_page" }};request.callback = (response) =>{Debug.Log("TCP Ping 結果: " + response);};Unity_CLS.TcpPing(request);
Unity_CLS.Ping(PingRequest request)
フィールド | タイプ | デフォルト値 | プラットフォーム対応 | 説明 |
target | string | "" | 全プラットフォーム | ターゲットホスト名またはIPアドレス |
count | int | 1 | 全プラットフォーム | プローブ回数 |
timeout | int | 1000 | 全プラットフォーム | タイムアウト時間(ミリ秒) |
packetSize | int | 100 | Windows/Android | データパケットサイズ(バイト、ICMPヘッダーを含まない) |
interval | int | 300 | Windows/iOS | プローブ間隔時間(ミリ秒) |
ttl | int | 64 | Windows | TTL値 |
prefer | int | 0 | Windows/iOS | IPバージョン優先設定 |
netId | int | 0 | Windows | ネットワークカードID |
traceId | string | null | 全プラットフォーム | トレースID |
src | string | null | Windows | ソース識別子 |
multiplePortsDetect | bool | true | Android | マルチポートプローブを実行するかどうか |
enableMultiplePortsDetect | bool | false | iOS | マルチポートプローブを有効にするかどうか |
detectCustomField | Dictionary | 空の辞書 | 全プラットフォーム | 検出拡張フィールド |
callback | callback_response | null | 全プラットフォーム | 結果コールバック関数 |
PingRequest request = new PingRequest();request.target = "www.baidu.com";request.count = 5;request.timeout = 3000;request.callback = (response) =>{Debug.Log("Ping 結果: " + response);};Unity_CLS.Ping(request);
Unity_CLS.Http(HttpRequest request)
フィールド | タイプ | デフォルト値 | プラットフォーム対応 | 説明 |
url | string | "" | 全プラットフォーム | ターゲットURL(http:// または https:// などのプロトコルヘッダーを含める必要があります) |
count | int | 1 | Android/iOS | プローブ回数 |
timeout | int | 1000 | 全プラットフォーム | タイムアウト時間(ミリ秒) |
interval | int | 300 | Windows | プローブ間隔時間(ミリ秒) |
ip | string | null | Android | 指定IPアドレス(nullの場合はDNS解決を使用します) |
downloadBytesLimit | int | 0 | Windows | ダウンロードバイト制限です。0は制限なしを表します。 |
downloadHeaderOnly | int | 0 | Windows | ヘッダーのみをダウンロードするかどうか 1:ヘッダーのみ 0:完全なコンテンツ |
verifySslCert | int | 0 | Windows/iOS | SSL証明書を検証するかどうか 1:検証 0:検証しない |
size | int | 0 | Android | 送信データパケットサイズ |
prefer | int | 0 | Windows/iOS | IPバージョン優先設定 |
netId | int | 0 | Windows | ネットワークカードID |
traceId | string | null | 全プラットフォーム | トレースID |
src | string | null | Windows | ソース識別子 |
multiplePortsDetect | bool | true | Android | マルチポートプローブを実行するかどうか |
enableMultiplePortsDetect | bool | false | iOS | マルチポートプローブを有効にするかどうか |
detectCustomField | Dictionary | 空の辞書 | 全プラットフォーム | 検出拡張フィールド |
callback | callback_response | null | 全プラットフォーム | 結果コールバック関数 |
HttpRequest request = new HttpRequest();request.url = "https://www.baidu.com";request.timeout = 5000;request.callback = (response) =>{Debug.Log("HTTP プローブ結果: " + response);};Unity_CLS.Http(request);
Unity_CLS.Dns(DnsRequest request)
フィールド | タイプ | デフォルト値 | プラットフォーム対応 | 説明 |
domain | string | "" | 全プラットフォーム | ターゲットドメイン |
type | string | null | Windows/Android | DNSクエリタイプ(「A」、「AAAA」など。nullの場合はデフォルトでA) |
servers | string | null | 全プラットフォーム | DNSサーバーリスト(カンマ区切り、例:「8.8.8.8,8.8.4.4」。nullの場合はシステムデフォルトを使用) |
count | int | 1 | Android | プローブ回数 |
timeout | int | 1000 | 全プラットフォーム | タイムアウト時間(ミリ秒) |
size | int | 0 | Android | 送信データパケットサイズ |
prefer | int | 0 | Windows/iOS | IPバージョン優先設定 |
traceId | string | null | 全プラットフォーム | トレースID |
src | string | null | Windows | ソース識別子 |
multiplePortsDetect | bool | true | Android | マルチポートプローブを実行するかどうか |
enableMultiplePortsDetect | bool | false | iOS | マルチポートプローブを有効にするかどうか |
detectCustomField | Dictionary | 空の辞書 | 全プラットフォーム | 検出拡張フィールド |
callback | callback_response | null | 全プラットフォーム | 結果コールバック関数 |
DnsRequest request = new DnsRequest();request.domain = "www.baidu.com";request.servers = "8.8.8.8";request.callback = (response) =>{Debug.Log("DNS 解析結果: " + response);};Unity_CLS.Dns(request);
Unity_CLS.Mtr(MtrRequest request)
フィールド | タイプ | デフォルト値 | プラットフォーム対応 | 説明 |
target | string | "" | 全プラットフォーム | ターゲットホスト名またはIPアドレス |
maxTtl | int | 30 | 全プラットフォーム | 最大TTL値(最大ホップ数、1~255) |
times | int | 10 | 全プラットフォーム | ホップごとのプローブ回数 |
timeout | int | 1000 | 全プラットフォーム | タイムアウト時間(ミリ秒) |
interval | int | 300 | Windows | 検出間隔時間(ミリ秒) |
protocol | string | "icmp" | Windows/Android | プロトコルタイプ(「icmp」、「tcp」、「udp」) |
destPort | int | 0 | Windows | ターゲットポート(TCP/UDPプロトコルで使用) |
maxPaths | int | 1 | Windows/Android | 最大パス数(1~10) |
size | int | 0 | Android | 送信データパケットサイズ |
prefer | int | 0 | Windows/iOS | IPバージョン優先設定 |
netId | int | 0 | Windows | ネットワークカードID |
traceId | string | null | 全プラットフォーム | トレースID |
src | string | null | Windows | ソース識別子 |
multiplePortsDetect | bool | true | Android | マルチポートプローブを実行するかどうか |
enableMultiplePortsDetect | bool | false | iOS | マルチポートプローブを有効にするかどうか |
detectCustomField | Dictionary | 空の辞書 | 全プラットフォーム | 検出拡張フィールド |
callback | callback_response | null | 全プラットフォーム | 結果コールバック関数 |
MtrRequest request = new MtrRequest();request.target = "www.baidu.com";request.maxTtl = 30;request.times = 5;request.protocol = "icmp";request.callback = (response) =>{Debug.Log("MTR 結果: " + response);};Unity_CLS.Mtr(request);
using System;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using TencentCloudCLS;public class NetworkDiagnosisManager : MonoBehaviour{void Start(){Debug.Log("[NetworkDiagnosis] 初期化を開始します...");}/// <summary>/// SDKを初期化します(すべての検出操作の前に呼び出す必要があります)/// </summary>public void Init(){Credential credential = new Credential();credential.endpoint = "ap-guangzhou.cls.tencentcs.com";credential.secretId = "お客様の SecretId";credential.secretKey = "お客様の SecretKey";credential.geoToken = "お客様の GeoToken";Unity_CLS.Initialize(credential);// ユーザーカスタム拡張フィールドを設定します。Dictionary<string, string> userCustomField = new Dictionary<string, string>();userCustomField.Add("app_version", "1.0.0");userCustomField.Add("scene", "main_menu");Unity_CLS.SetUserCustom(userCustomField);Debug.Log("[NetworkDiagnosis] 初期化が完了しました");}/// <summary>/// TCP Pingプローブを実行します。/// </summary>public void DoTcpPing(){TcpPingRequest request = new TcpPingRequest();request.target = "www.baidu.com";request.port = 80;request.count = 3;request.detectCustomField = new Dictionary<string, string>(){{ "test_type", "tcp_ping" }};request.callback = (response) =>{Debug.Log("[TCP Ping] 結果: " + response);};Unity_CLS.TcpPing(request);}/// <summary>/// ICMP Pingプローブを実行します。/// </summary>public void DoPing(){PingRequest request = new PingRequest();request.target = "www.baidu.com";request.count = 5;request.detectCustomField = new Dictionary<string, string>(){{ "test_type", "icmp_ping" }};request.callback = (response) =>{Debug.Log("[Ping] 結果: " + response);};Unity_CLS.Ping(request);}/// <summary>/// HTTPプローブを実行します。/// </summary>public void DoHttp(){HttpRequest request = new HttpRequest();request.url = "http://www.baidu.com";request.timeout = 5000;request.detectCustomField = new Dictionary<string, string>(){{ "test_type", "http" }};request.callback = (response) =>{Debug.Log("[HTTP] 結果: " + response);};Unity_CLS.Http(request);}/// <summary>/// DNS解決プローブを実行します。/// </summary>public void DoDns(){DnsRequest request = new DnsRequest();request.domain = "www.baidu.com";request.detectCustomField = new Dictionary<string, string>(){{ "test_type", "dns" }};request.callback = (response) =>{Debug.Log("[DNS] 結果: " + response);};Unity_CLS.Dns(request);}/// <summary>/// MTRルート追跡を実行します。/// </summary>public void DoMtr(){MtrRequest request = new MtrRequest();request.target = "www.baidu.com";request.maxTtl = 30;request.times = 3;request.detectCustomField = new Dictionary<string, string>(){{ "test_type", "mtr" }};request.callback = (response) =>{Debug.Log("[MTR] 結果: " + response);};Unity_CLS.Mtr(request);}}
public delegate void callback_response(string response);
Dictionary<string, string> userCustomField = new Dictionary<string, string>();userCustomField.Add("user_id", "12345");userCustomField.Add("app_version", "2.0.0");Unity_CLS.SetUserCustom(userCustomField);
request.detectCustomField = new Dictionary<string, string>(){{ "scene", "game_loading" },{ "server_region", "ap-shanghai" }};
パラメータ | Windows | Android | iOS |
interval(プローブ間隔) | ✅ | ❌ | 部分的な対応 |
prefer(IPバージョン優先設定) | ✅ | ❌ | ✅ |
netId(ネットワークカードID) | ✅ | ❌ | ❌ |
src(ソース識別子) | ✅ | ❌ | ❌ |
multiplePortsDetect | ❌ | ✅ | ❌ |
enableMultiplePortsDetect | ❌ | ❌ | ✅ |
enableVerification(TCP) | ✅ | ❌ | ❌ |
payload(TCP) | ✅ | ✅ | ❌ |
protocol(MTR) | ✅ | ✅ | ✅ |
プラットフォーム | 実現方法 |
Windows / Editor | DLL(cls_network_detect.dll)P/Invoke を介して C ネイティブライブラリを呼び出します。 |
Android | AndroidJavaClass を介して Java 層 SDK(AAR パッケージ)を呼び出します。 |
iOS | DllImport __Internal を介して Objective-C ブリッジ層(UnityApi.m → TencentCloudLogProducer.framework)を呼び出します。 |
フィードバック