网络连接兼容socket和ws
This commit is contained in:
parent
4002cbd452
commit
64adbabfab
@ -125,6 +125,15 @@ public class SocketConn
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
连接服务器gate端口规则:
|
||||
1. Editor模式使用ip和固定端口:6411
|
||||
2. WebGL包使用http和ws协议的,使用ip和端口:6412
|
||||
3. WebGL包使用https和wss协议的,使用域名和固定端口:4430
|
||||
连接服务器serverlist端口规则:
|
||||
1. ip+端口模式:使用端口 6410
|
||||
2. 域名模式:使用https默认端口443
|
||||
*/
|
||||
public bool Connect(string host, int port, float timeout = 1f)
|
||||
{
|
||||
if (mSocketState != enSocketState.Disconnected)
|
||||
@ -152,7 +161,7 @@ public class SocketConn
|
||||
string address = "";
|
||||
if (CommonUtil.IsValidIPv4(host))
|
||||
{
|
||||
address = string.Format("ws://{0}:{1}", host, port);
|
||||
address = string.Format("ws://{0}:{1}", host, 6412);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -170,6 +179,8 @@ public class SocketConn
|
||||
mLastPort = port;
|
||||
m_fBeginConnectTime = Time.realtimeSinceStartup;
|
||||
#else
|
||||
// Editor 模式固定端口 6411
|
||||
port = 6411;
|
||||
mSocket = new Socket(newAddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
IPAddress addr = IPAddress.Parse(newServerIp);
|
||||
IPEndPoint endpoint = new IPEndPoint(addr, port);
|
||||
|
||||
@ -1454,7 +1454,9 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
|
||||
yield break;
|
||||
}
|
||||
|
||||
int loadCount = 0;
|
||||
List<RuntimeAnimatorController> racs = new List<RuntimeAnimatorController>();
|
||||
Dictionary<string, RuntimeAnimatorController> assetDict = new Dictionary<string, RuntimeAnimatorController>();
|
||||
string path = "";
|
||||
for (int i = 0; i < assetName.Length; ++i)
|
||||
{
|
||||
@ -1470,11 +1472,20 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
|
||||
}
|
||||
|
||||
//RuntimeAnimatorController rac = UnityEditor.AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(path);
|
||||
var handle = Addressables.LoadAssetAsync<RuntimeAnimatorController>(path);
|
||||
yield return handle;
|
||||
racs.Add(handle.Result);
|
||||
var currAssetName = assetName[i];
|
||||
Addressables.LoadAssetAsync<RuntimeAnimatorController>(path).Completed += handle =>
|
||||
{
|
||||
assetDict[currAssetName] = handle.Result;
|
||||
loadCount++;
|
||||
};
|
||||
}
|
||||
}
|
||||
while (loadCount < assetName.Length) { yield return null; }
|
||||
|
||||
for (int i = 0; i < assetName.Length; ++i)
|
||||
{
|
||||
racs.Add(assetDict[assetName[i]]);
|
||||
}
|
||||
if (Application.isPlaying)
|
||||
yield return new WaitForEndOfFrame();
|
||||
callback.DynamicInvoke(racs, seqId, pathName, assetName);
|
||||
@ -1482,6 +1493,8 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
|
||||
else if (typeof(T).Equals(typeof(List<AudioClip>)))
|
||||
{
|
||||
List<AudioClip> gos = new List<AudioClip>();
|
||||
int loadCount = 0;
|
||||
Dictionary<string, AudioClip> dict = new Dictionary<string, AudioClip>();
|
||||
for (int i = 0; i < assetName.Length; ++i)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(assetName[i]))
|
||||
@ -1496,11 +1509,19 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
|
||||
}
|
||||
|
||||
//AudioClip ac = UnityEditor.AssetDatabase.LoadAssetAtPath<AudioClip>(path);
|
||||
var handle = Addressables.LoadAssetAsync<AudioClip>(path);
|
||||
yield return handle;
|
||||
gos.Add(handle.Result);
|
||||
var currAssetName = assetName[i];
|
||||
Addressables.LoadAssetAsync<AudioClip>(path).Completed += handle =>
|
||||
{
|
||||
dict[currAssetName] = handle.Result;
|
||||
loadCount++;
|
||||
};
|
||||
}
|
||||
}
|
||||
while (loadCount < assetName.Length) { yield return null; }
|
||||
for (int i = 0; i < assetName.Length; ++i)
|
||||
{
|
||||
gos.Add(dict[assetName[i]]);
|
||||
}
|
||||
|
||||
if (Application.isPlaying)
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
@ -54,9 +54,14 @@ public class LuaMgr : SingletonMono<LuaMgr>
|
||||
{
|
||||
var tolua_zip_data = await AssetsMgr.Instance.LoadLocalFileData(Application.streamingAssetsPath + "/" + Constants.LuaDirMergeFile);
|
||||
UnzipLuaFiles(tolua_zip_data);
|
||||
GC.Collect();
|
||||
long before = GC.GetTotalMemory(true);
|
||||
var lua_zip_data = await AssetsMgr.Instance.LoadLocalFileData(Application.streamingAssetsPath + "/" + Constants.LuaLogicDirMergeFile);
|
||||
//UnzipLuaFiles(lua_zip_data);
|
||||
|
||||
_luaLogicZip = CommonUtil.GetZipFile(lua_zip_data);
|
||||
long after = GC.GetTotalMemory(true);
|
||||
Debug.Log($"_luaLogicZip size: {before} : {after}");
|
||||
var pb_zip_data = await AssetsMgr.Instance.LoadLocalFileData(Application.streamingAssetsPath + "/" + Constants.LuaPbDirMergeFile);
|
||||
UnzipPbFiles(pb_zip_data);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user