| | |
| | | using System.Net.Sockets; |
| | | using System.IO; |
| | | using System.Text.RegularExpressions; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | #if UNITY_IOS |
| | | using UnityEngine.iOS; |
| | |
| | | |
| | | static string ipPattern = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"; |
| | | static string ip = string.Empty; |
| | | public static string GetIp() |
| | | public static async UniTask<string> GetIp() |
| | | { |
| | | try |
| | | { |
| | |
| | | WebRequest wRequest = WebRequest.Create(url); |
| | | wRequest.Method = "GET"; |
| | | wRequest.ContentType = "text/html;charset=UTF-8"; |
| | | WebResponse wResponse = wRequest.GetResponse(); |
| | | WebResponse wResponse = await wRequest.GetResponseAsync(); |
| | | Stream stream = wResponse.GetResponseStream(); |
| | | StreamReader reader = new StreamReader(stream, System.Text.Encoding.Default); |
| | | string str = reader.ReadToEnd(); |
| | | string str = await reader.ReadToEndAsync(); |
| | | |
| | | reader.Close(); |
| | | wResponse.Close(); |
| | |
| | | ip = match.Value; |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.Log(ex); |
| | | } |
| | | |
| | | return ip; |
| | | } |
| | | |