网络兼容ip和https
This commit is contained in:
parent
bd4cff9a90
commit
30fbb86874
@ -148,9 +148,12 @@ public class SocketConn
|
||||
#endif
|
||||
try
|
||||
{
|
||||
|
||||
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||
m_address = string.Format("wss://{0}:{1}", host, 4430);
|
||||
if (CommonUtil.IsValidIPv4(host) == false)
|
||||
{
|
||||
port = 4430;
|
||||
}
|
||||
m_address = string.Format("wss://{0}:{1}", host, port);
|
||||
Debug.LogWarning("Begin connect to Socket Address :" + m_address);
|
||||
m_iSocket = new WebSocket(m_address);
|
||||
m_iSocket.OnOpen += Socket_OnOpen;
|
||||
|
||||
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public static class CommonUtil
|
||||
{
|
||||
@ -410,4 +411,10 @@ public static class CommonUtil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsValidIPv4(string ip)
|
||||
{
|
||||
string pattern = @"^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$";
|
||||
return Regex.IsMatch(ip, pattern);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user