From 30f188cbae709f1d0edb101172a0e9ccdf69fbc2 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 11:01:24 +0800
Subject: [PATCH 01/66] =?UTF-8?q?=E6=95=B4=E7=90=86=E7=9B=AE=E5=BD=95?=
=?UTF-8?q?=E7=BB=93=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.asmdef | 0
Editor.meta | 8 +
Editor/Help.cs | 45 ++
Editor/Help.cs.meta | 11 +
Editor/PlayerSettingChecker.cs | 74 ++++
Editor/PlayerSettingChecker.cs.meta | 11 +
Editor/UnityWebSocket.Editor.asmdef | 16 +
Editor/UnityWebSocket.Editor.asmdef.meta | 7 +
Editor/VersionChecker.cs | 98 +++++
Editor/VersionChecker.cs.meta | 11 +
Example.meta | 10 +
Example/Example.cs | 178 ++++++++
Example/Example.cs.meta | 12 +
Example/Example.unity | 240 +++++++++++
Example/Example.unity.meta | 7 +
Example/UnityWebSocket.Example.asmdef | 14 +
Example/UnityWebSocket.Example.asmdef.meta | 7 +
Plugins.meta | 9 +
Plugins/WebGL.meta | 8 +
Plugins/WebGL/WebSocket.jslib | 349 +++++++++++++++
Plugins/WebGL/WebSocket.jslib.meta | 37 ++
Runtime.meta | 8 +
Runtime/Core.meta | 8 +
Runtime/Core/CloseEventArgs.cs | 89 ++++
Runtime/Core/CloseEventArgs.cs.meta | 11 +
Runtime/Core/CloseStatusCode.cs | 91 ++++
Runtime/Core/CloseStatusCode.cs.meta | 11 +
Runtime/Core/ErrorEventArgs.cs | 59 +++
Runtime/Core/ErrorEventArgs.cs.meta | 11 +
Runtime/Core/IWebSocket.cs | 156 +++++++
Runtime/Core/IWebSocket.cs.meta | 11 +
Runtime/Core/MessageEventArgs.cs | 132 ++++++
Runtime/Core/MessageEventArgs.cs.meta | 11 +
Runtime/Core/Opcode.cs | 38 ++
Runtime/Core/Opcode.cs.meta | 11 +
Runtime/Core/OpenEventArgs.cs | 11 +
Runtime/Core/OpenEventArgs.cs.meta | 11 +
Runtime/Core/Settings.cs | 11 +
Runtime/Core/Settings.cs.meta | 11 +
Runtime/Core/WebSocketState.cs | 36 ++
Runtime/Core/WebSocketState.cs.meta | 11 +
Runtime/Implementation.meta | 8 +
Runtime/Implementation/NoWebGL.meta | 8 +
Runtime/Implementation/NoWebGL/WebSocket.cs | 401 ++++++++++++++++++
.../Implementation/NoWebGL/WebSocket.cs.meta | 11 +
Runtime/Implementation/Synchronized.meta | 8 +
.../Implementation/Synchronized/WebSocket.cs | 131 ++++++
.../Synchronized/WebSocket.cs.meta | 11 +
.../Synchronized/WebSocketManager.cs | 65 +++
.../Synchronized/WebSocketManager.cs.meta | 11 +
Runtime/Implementation/Uniform.meta | 8 +
Runtime/Implementation/Uniform/WebSocket.cs | 72 ++++
.../Implementation/Uniform/WebSocket.cs.meta | 11 +
Runtime/Implementation/WebGL.meta | 8 +
Runtime/Implementation/WebGL/WebSocket.cs | 90 ++++
.../Implementation/WebGL/WebSocket.cs.meta | 12 +
.../Implementation/WebGL/WebSocketManager.cs | 172 ++++++++
.../WebGL/WebSocketManager.cs.meta | 11 +
Runtime/UnityWebSocket.Runtime.asmdef | 12 +
Runtime/UnityWebSocket.Runtime.asmdef.meta | 7 +
60 files changed, 2947 insertions(+)
create mode 100644 .asmdef
create mode 100644 Editor.meta
create mode 100644 Editor/Help.cs
create mode 100644 Editor/Help.cs.meta
create mode 100644 Editor/PlayerSettingChecker.cs
create mode 100644 Editor/PlayerSettingChecker.cs.meta
create mode 100644 Editor/UnityWebSocket.Editor.asmdef
create mode 100644 Editor/UnityWebSocket.Editor.asmdef.meta
create mode 100644 Editor/VersionChecker.cs
create mode 100644 Editor/VersionChecker.cs.meta
create mode 100644 Example.meta
create mode 100644 Example/Example.cs
create mode 100644 Example/Example.cs.meta
create mode 100644 Example/Example.unity
create mode 100644 Example/Example.unity.meta
create mode 100644 Example/UnityWebSocket.Example.asmdef
create mode 100644 Example/UnityWebSocket.Example.asmdef.meta
create mode 100644 Plugins.meta
create mode 100644 Plugins/WebGL.meta
create mode 100644 Plugins/WebGL/WebSocket.jslib
create mode 100644 Plugins/WebGL/WebSocket.jslib.meta
create mode 100644 Runtime.meta
create mode 100644 Runtime/Core.meta
create mode 100644 Runtime/Core/CloseEventArgs.cs
create mode 100644 Runtime/Core/CloseEventArgs.cs.meta
create mode 100644 Runtime/Core/CloseStatusCode.cs
create mode 100644 Runtime/Core/CloseStatusCode.cs.meta
create mode 100644 Runtime/Core/ErrorEventArgs.cs
create mode 100644 Runtime/Core/ErrorEventArgs.cs.meta
create mode 100644 Runtime/Core/IWebSocket.cs
create mode 100644 Runtime/Core/IWebSocket.cs.meta
create mode 100644 Runtime/Core/MessageEventArgs.cs
create mode 100644 Runtime/Core/MessageEventArgs.cs.meta
create mode 100644 Runtime/Core/Opcode.cs
create mode 100644 Runtime/Core/Opcode.cs.meta
create mode 100644 Runtime/Core/OpenEventArgs.cs
create mode 100644 Runtime/Core/OpenEventArgs.cs.meta
create mode 100644 Runtime/Core/Settings.cs
create mode 100644 Runtime/Core/Settings.cs.meta
create mode 100644 Runtime/Core/WebSocketState.cs
create mode 100644 Runtime/Core/WebSocketState.cs.meta
create mode 100644 Runtime/Implementation.meta
create mode 100644 Runtime/Implementation/NoWebGL.meta
create mode 100644 Runtime/Implementation/NoWebGL/WebSocket.cs
create mode 100644 Runtime/Implementation/NoWebGL/WebSocket.cs.meta
create mode 100644 Runtime/Implementation/Synchronized.meta
create mode 100644 Runtime/Implementation/Synchronized/WebSocket.cs
create mode 100644 Runtime/Implementation/Synchronized/WebSocket.cs.meta
create mode 100644 Runtime/Implementation/Synchronized/WebSocketManager.cs
create mode 100644 Runtime/Implementation/Synchronized/WebSocketManager.cs.meta
create mode 100644 Runtime/Implementation/Uniform.meta
create mode 100644 Runtime/Implementation/Uniform/WebSocket.cs
create mode 100644 Runtime/Implementation/Uniform/WebSocket.cs.meta
create mode 100644 Runtime/Implementation/WebGL.meta
create mode 100644 Runtime/Implementation/WebGL/WebSocket.cs
create mode 100644 Runtime/Implementation/WebGL/WebSocket.cs.meta
create mode 100644 Runtime/Implementation/WebGL/WebSocketManager.cs
create mode 100644 Runtime/Implementation/WebGL/WebSocketManager.cs.meta
create mode 100644 Runtime/UnityWebSocket.Runtime.asmdef
create mode 100644 Runtime/UnityWebSocket.Runtime.asmdef.meta
diff --git a/.asmdef b/.asmdef
new file mode 100644
index 00000000..e69de29b
diff --git a/Editor.meta b/Editor.meta
new file mode 100644
index 00000000..567ca440
--- /dev/null
+++ b/Editor.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: bb71bb4fb62590c4b975ef865b4df25f
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/Help.cs b/Editor/Help.cs
new file mode 100644
index 00000000..e2e407b6
--- /dev/null
+++ b/Editor/Help.cs
@@ -0,0 +1,45 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace UnityWebSocket.Editor
+{
+ public class About
+ {
+ [MenuItem("Tools/UnityWebSocket/Help/Home Page")]
+ public static void HelpHomePage()
+ {
+ Application.OpenURL(Settings.GITHUB);
+ }
+
+ [MenuItem("Tools/UnityWebSocket/Help/Report an Issue")]
+ public static void HelpReportIssue()
+ {
+ Application.OpenURL(Settings.GITHUB + "/issues/new");
+ }
+
+ [MenuItem("Tools/UnityWebSocket/Help/Feedback")]
+ public static void HelpContact()
+ {
+ var uri = new System.Uri(string.Format("mailto:{0}?subject={1}", Settings.EMAIL, "UnityWebSocket Feedback"));
+ Application.OpenURL(uri.AbsoluteUri);
+ }
+
+ [MenuItem("Tools/UnityWebSocket/Help/QQ群")]
+ public static void HelpContactQQ()
+ {
+ Application.OpenURL(Settings.QQ);
+ }
+
+ [MenuItem("Tools/UnityWebSocket/About")]
+ public static void AboutDialog()
+ {
+ var title = "UnityWebSocket";
+ var content = "\n"
+ + $"Version: {Settings.VERSION}\n\n"
+ + $"Author: {Settings.AUHTOR}\n\n"
+ + $"E-mail: {Settings.EMAIL}\n\n"
+ + $"All rights reserved";
+ EditorUtility.DisplayDialog(title, content, "OK");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Editor/Help.cs.meta b/Editor/Help.cs.meta
new file mode 100644
index 00000000..1ee9d407
--- /dev/null
+++ b/Editor/Help.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6a935232acb8147108f2b80751be5d2f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/PlayerSettingChecker.cs b/Editor/PlayerSettingChecker.cs
new file mode 100644
index 00000000..d6236b7f
--- /dev/null
+++ b/Editor/PlayerSettingChecker.cs
@@ -0,0 +1,74 @@
+using UnityEditor;
+
+namespace UnityWebSocket.Editor
+{
+ public class PlayerSettingChecker
+ {
+#if UNITY_2018_1_OR_NEWER
+ [MenuItem("Tools/UnityWebSocket/LinkerTarget/Wasm", false, 1)]
+ private static void WebSocketSettingLinkerTargetWasm()
+ {
+ PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
+ }
+
+ [MenuItem("Tools/UnityWebSocket/LinkerTarget/Wasm", true, 1)]
+ private static bool WebSocketSettingLinkerTargetWasmValidate()
+ {
+ return false;
+ }
+
+ [MenuItem("Tools/UnityWebSocket/LinkerTarget/asm.js", false, 0)]
+ private static void WebSocketSettingLinkerTargetAsm()
+ {
+ PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Asm;
+ }
+
+ [MenuItem("Tools/UnityWebSocket/LinkerTarget/Both", false, 2)]
+ private static void WebSocketSettingLinkerTargetBoth()
+ {
+ PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;
+ }
+
+ // [MenuItem("Tools/UnityWebSocket/Check Settings", false, 10)]
+ private static void CheckSettings()
+ {
+ if (PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Wasm)
+ {
+ EditorUtility.DisplayDialog("Warning"
+ , "On WebGL platform WebGL Linker Target should be asm.js or Both, via Menu:\nUnityWebSocket -> LinkerTarget -> asm.js or Both"
+ , "OK");
+ }
+ else if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy)
+ {
+ EditorUtility.DisplayDialog("Warning"
+ , "Scripting Runtime Version should be .NET 4.x, via Menu:\nPlayerSettings -> Other Settings -> Scripting Runtime Version -> .Net 4.x Equivalent"
+ , "OK");
+ }
+ else
+ {
+ EditorUtility.DisplayDialog("Success"
+ , "Your settings is OK."
+ , "OK");
+ }
+ }
+
+ [InitializeOnLoadMethod]
+ public static void OnInit()
+ {
+ if (PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Wasm)
+ {
+ EditorUtility.DisplayDialog("Warning"
+ , "On WebGL platform WebGL Linker Target should be Asm or Both, via Menu:\nUnityWebSocket -> LinkerTarget -> Asm or Both"
+ , "OK");
+ }
+
+ if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy)
+ {
+ EditorUtility.DisplayDialog("Warning"
+ , "Scripting Runtime Version should be .NET 4.x, via Menu:\nPlayerSettings -> Other Settings -> Scripting Runtime Version -> .Net 4.x Equivalent"
+ , "OK");
+ }
+ }
+#endif
+ }
+}
\ No newline at end of file
diff --git a/Editor/PlayerSettingChecker.cs.meta b/Editor/PlayerSettingChecker.cs.meta
new file mode 100644
index 00000000..75c51564
--- /dev/null
+++ b/Editor/PlayerSettingChecker.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5031c7d4e788047639083e2fe2aa5787
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/UnityWebSocket.Editor.asmdef b/Editor/UnityWebSocket.Editor.asmdef
new file mode 100644
index 00000000..9ae7fa49
--- /dev/null
+++ b/Editor/UnityWebSocket.Editor.asmdef
@@ -0,0 +1,16 @@
+{
+ "name": "UnityWebSocket.Editor",
+ "references": [
+ "UnityWebSocket.Runtime"
+ ],
+ "optionalUnityReferences": [],
+ "includePlatforms": [
+ "Editor"
+ ],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": []
+}
\ No newline at end of file
diff --git a/Editor/UnityWebSocket.Editor.asmdef.meta b/Editor/UnityWebSocket.Editor.asmdef.meta
new file mode 100644
index 00000000..851d4552
--- /dev/null
+++ b/Editor/UnityWebSocket.Editor.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ee833745c57bd4369ab8f0ff380a96fa
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/VersionChecker.cs b/Editor/VersionChecker.cs
new file mode 100644
index 00000000..cdc46c54
--- /dev/null
+++ b/Editor/VersionChecker.cs
@@ -0,0 +1,98 @@
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Networking;
+using UnityWebSocket;
+
+namespace UnityWebSocket.Editor
+{
+ public class VersionChecker
+ {
+#if UNITY_2018_1_OR_NEWER
+ static UnityWebRequest req;
+ static bool forceCheck = false;
+
+ [InitializeOnLoadMethod]
+ public static void OnInit()
+ {
+ forceCheck = false;
+ BeginCheck();
+ }
+
+ private static void Update()
+ {
+ if (req == null || req.isNetworkError || req.isHttpError)
+ {
+ EditorApplication.update -= Update;
+ return;
+ }
+
+ if (req.isDone)
+ {
+ EditorApplication.update -= Update;
+ var latestVersion = req.url.Substring(req.url.LastIndexOf("/v") + 2);
+ var vKey = "UnityWebSocket_Version_Skip_v" + latestVersion;
+ if (!forceCheck && EditorPrefs.GetBool(vKey, false))
+ return;
+
+ if (EditorPrefs.HasKey(vKey))
+ {
+ EditorPrefs.DeleteKey(vKey);
+ }
+
+ if (Settings.VERSION != latestVersion)
+ {
+ var text = req.downloadHandler.text;
+ var st = text.IndexOf("content=\"v" + latestVersion);
+ st = st > 0 ? text.IndexOf("\n", st) : -1;
+ var end = st > 0 ? text.IndexOf("\" />", st) : -1;
+ var changeLog = "";
+ if (st > 0 && end > st)
+ {
+ changeLog = text.Substring(st + 1, end - st - 1).Trim();
+ changeLog = changeLog.Replace("\r", "");
+ changeLog = changeLog.Replace("\n", "\n- ");
+ changeLog = "\nCHANGE LOG: \n- " + changeLog + "\n";
+ }
+
+ var code = EditorUtility.DisplayDialogComplex("UnityWebSocket"
+ , "UnityWebSocket new version found v" + latestVersion
+ + ", your current version is v" + Settings.VERSION + ".\n"
+ + "Upgrade UnityWebSocket now?\n"
+ + changeLog,
+ "Upgrade Now", "Remind Me Later", "Skip this Version");
+
+ if (code == 0)
+ {
+ Application.OpenURL(Settings.GITHUB + "/releases");
+ }
+ else if (code == 2)
+ {
+ EditorPrefs.SetBool(vKey, true);
+ }
+ }
+ else if (forceCheck)
+ {
+ EditorUtility.DisplayDialog("UnityWebSocket", "Your current version v" + Settings.VERSION + " is the Latest version.", "OK");
+ }
+ }
+ }
+
+ [MenuItem("Tools/UnityWebSocket/Check Updates", priority = 10)]
+ static void CheckUpdates()
+ {
+ forceCheck = true;
+ BeginCheck();
+ }
+
+ static void BeginCheck()
+ {
+ req = UnityWebRequest.Get(Settings.GITHUB + "/releases/latest");
+
+ EditorApplication.update -= Update;
+ EditorApplication.update += Update;
+
+ req.SendWebRequest();
+ }
+#endif
+ }
+}
\ No newline at end of file
diff --git a/Editor/VersionChecker.cs.meta b/Editor/VersionChecker.cs.meta
new file mode 100644
index 00000000..762c9099
--- /dev/null
+++ b/Editor/VersionChecker.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: eaa5f470aa7fe422da0f1a17b59273a6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Example.meta b/Example.meta
new file mode 100644
index 00000000..5b38e38e
--- /dev/null
+++ b/Example.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 1b26d420fd41d1643b77c70b1fcc075f
+folderAsset: yes
+timeCreated: 1530672580
+licenseType: Pro
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Example/Example.cs b/Example/Example.cs
new file mode 100644
index 00000000..3319cda7
--- /dev/null
+++ b/Example/Example.cs
@@ -0,0 +1,178 @@
+using System;
+using UnityEngine;
+using UnityWebSocket;
+
+public class Example : MonoBehaviour
+{
+ public string url = "ws://echo.websocket.org";
+ private IWebSocket socket;
+
+ string sendText = "Test123 \\/*1#&^`";
+ string log = "";
+ int sendCount;
+ int receiveCount;
+ Vector2 scrollPos;
+ bool logMessage = true;
+
+ private void OnGUI()
+ {
+ var scale = Screen.width / 800f;
+ GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(scale, scale, 1));
+ var width = GUILayout.Width(Screen.width / scale - 10);
+
+ WebSocketState state = socket == null ? WebSocketState.Closed : socket.ReadyState;
+
+ GUILayout.Label("SDK Version: " + Settings.VERSION, width);
+ var stateColor = state == WebSocketState.Closed ? "red" : state == WebSocketState.Open ? "#11ff11" : "#aa4444";
+ var richText = new GUIStyle() { richText = true };
+ GUILayout.Label(string.Format(" State: {0}", state, stateColor), richText);
+
+ GUI.enabled = state == WebSocketState.Closed;
+ GUILayout.Label("URL: ", width);
+ url = GUILayout.TextField(url, width);
+
+ GUILayout.BeginHorizontal();
+ GUI.enabled = state == WebSocketState.Closed;
+ if (GUILayout.Button(state == WebSocketState.Connecting ? "Connecting..." : "Connect"))
+ {
+ socket = new WebSocket(url);
+ socket.OnOpen += Socket_OnOpen;
+ socket.OnMessage += Socket_OnMessage;
+ socket.OnClose += Socket_OnClose;
+ socket.OnError += Socket_OnError;
+ AddLog(string.Format("Connecting...\n"));
+ socket.ConnectAsync();
+ }
+
+ GUI.enabled = state == WebSocketState.Open;
+ if (GUILayout.Button(state == WebSocketState.Closing ? "Closing..." : "Close"))
+ {
+ AddLog(string.Format("Closing...\n"));
+ socket.CloseAsync();
+ }
+ GUILayout.EndHorizontal();
+
+ GUILayout.Label("Text: ");
+ sendText = GUILayout.TextArea(sendText, GUILayout.MinHeight(50), width);
+
+ GUILayout.BeginHorizontal();
+ if (GUILayout.Button("Send"))
+ {
+ if (!string.IsNullOrEmpty(sendText))
+ {
+ socket.SendAsync(sendText, () =>
+ {
+ if (logMessage)
+ AddLog(string.Format("Send: {0}\n", sendText));
+ sendCount += 1;
+ });
+ }
+ }
+ if (GUILayout.Button("Send Bytes"))
+ {
+ if (!string.IsNullOrEmpty(sendText))
+ {
+ var bytes = System.Text.Encoding.UTF8.GetBytes(sendText);
+ socket.SendAsync(bytes, () =>
+ {
+ if (logMessage)
+ AddLog(string.Format("Send Bytes ({1}): {0}\n", sendText, bytes.Length));
+ sendCount += 1;
+ });
+ }
+ }
+ if (GUILayout.Button("Send x100"))
+ {
+ if (!string.IsNullOrEmpty(sendText))
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ var text = (i + 1).ToString() + ". " + sendText;
+ socket.SendAsync(text, () =>
+ {
+ if (logMessage)
+ AddLog(string.Format("Send: {0}\n", text));
+ sendCount += 1;
+ });
+ }
+ }
+ }
+ if (GUILayout.Button("Send Bytes x100"))
+ {
+ if (!string.IsNullOrEmpty(sendText))
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ var text = (i + 1).ToString() + ". " + sendText;
+ var bytes = System.Text.Encoding.UTF8.GetBytes(text);
+ socket.SendAsync(bytes, () =>
+ {
+ if (logMessage)
+ AddLog(string.Format("Send Bytes ({1}): {0}\n", text, bytes.Length));
+ sendCount += 1;
+ });
+ }
+ }
+ }
+ GUILayout.EndHorizontal();
+
+ GUI.enabled = true;
+ GUILayout.BeginHorizontal();
+ logMessage = GUILayout.Toggle(logMessage, "Log Message");
+ GUILayout.Label(string.Format("Send ({0}): ", sendCount));
+ GUILayout.Label(string.Format("Receive ({0}): ", receiveCount));
+ GUILayout.EndHorizontal();
+
+ if (GUILayout.Button("Clear"))
+ {
+ log = "";
+ receiveCount = 0;
+ sendCount = 0;
+ }
+
+ scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.MaxHeight(Screen.height / scale - 270), width);
+ GUILayout.Label(log);
+ GUILayout.EndScrollView();
+ }
+
+ private void AddLog(string str)
+ {
+ log += str;
+ // max log
+ if (log.Length > 32 * 1024)
+ {
+ log = log.Substring(16 * 1024);
+ }
+ }
+
+ private void Socket_OnOpen(object sender, OpenEventArgs e)
+ {
+ AddLog(string.Format("Connected: {0}\n", url));
+ }
+
+ private void Socket_OnMessage(object sender, MessageEventArgs e)
+ {
+ if (e.IsBinary)
+ {
+ if (logMessage)
+ AddLog(string.Format("Receive Bytes ({1}): {0}\n", e.Data, e.RawData.Length));
+ }
+ else if (e.IsText)
+ {
+ if (logMessage)
+ AddLog(string.Format("Receive: {0}\n", e.Data));
+ }
+ receiveCount += 1;
+ }
+
+ private void Socket_OnClose(object sender, CloseEventArgs e)
+ {
+ AddLog(string.Format("Closed, StatusCode: {0}, Reason: {1}\n", e.StatusCode, e.Reason));
+ }
+
+ private void Socket_OnError(object sender, ErrorEventArgs e)
+ {
+ AddLog(string.Format("Error: {0}\n", e.Message));
+ }
+
+}
\ No newline at end of file
diff --git a/Example/Example.cs.meta b/Example/Example.cs.meta
new file mode 100644
index 00000000..aa3c1474
--- /dev/null
+++ b/Example/Example.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: c1b55962346f6de40bd5e924df2854fb
+timeCreated: 1466599118
+licenseType: Pro
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Example/Example.unity b/Example/Example.unity
new file mode 100644
index 00000000..676203bf
--- /dev/null
+++ b/Example/Example.unity
@@ -0,0 +1,240 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!29 &1
+OcclusionCullingSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 2
+ m_OcclusionBakeSettings:
+ smallestOccluder: 5
+ smallestHole: 0.25
+ backfaceThreshold: 100
+ m_SceneGUID: 00000000000000000000000000000000
+ m_OcclusionCullingData: {fileID: 0}
+--- !u!104 &2
+RenderSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 9
+ m_Fog: 0
+ m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
+ m_FogMode: 3
+ m_FogDensity: 0.01
+ m_LinearFogStart: 0
+ m_LinearFogEnd: 300
+ m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
+ m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
+ m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
+ m_AmbientIntensity: 1
+ m_AmbientMode: 0
+ m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
+ m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
+ m_HaloStrength: 0.5
+ m_FlareStrength: 1
+ m_FlareFadeSpeed: 3
+ m_HaloTexture: {fileID: 0}
+ m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
+ m_DefaultReflectionMode: 0
+ m_DefaultReflectionResolution: 128
+ m_ReflectionBounces: 1
+ m_ReflectionIntensity: 1
+ m_CustomReflection: {fileID: 0}
+ m_Sun: {fileID: 0}
+ m_IndirectSpecularColor: {r: 0.37311926, g: 0.38073996, b: 0.35872698, a: 1}
+ m_UseRadianceAmbientProbe: 0
+--- !u!157 &3
+LightmapSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 11
+ m_GIWorkflowMode: 0
+ m_GISettings:
+ serializedVersion: 2
+ m_BounceScale: 1
+ m_IndirectOutputScale: 1
+ m_AlbedoBoost: 1
+ m_EnvironmentLightingMode: 0
+ m_EnableBakedLightmaps: 1
+ m_EnableRealtimeLightmaps: 1
+ m_LightmapEditorSettings:
+ serializedVersion: 10
+ m_Resolution: 2
+ m_BakeResolution: 40
+ m_AtlasSize: 1024
+ m_AO: 0
+ m_AOMaxDistance: 1
+ m_CompAOExponent: 1
+ m_CompAOExponentDirect: 0
+ m_Padding: 2
+ m_LightmapParameters: {fileID: 0}
+ m_LightmapsBakeMode: 1
+ m_TextureCompression: 1
+ m_FinalGather: 0
+ m_FinalGatherFiltering: 1
+ m_FinalGatherRayCount: 256
+ m_ReflectionCompression: 2
+ m_MixedBakeMode: 2
+ m_BakeBackend: 1
+ m_PVRSampling: 1
+ m_PVRDirectSampleCount: 32
+ m_PVRSampleCount: 500
+ m_PVRBounces: 2
+ m_PVRFilterTypeDirect: 0
+ m_PVRFilterTypeIndirect: 0
+ m_PVRFilterTypeAO: 0
+ m_PVRFilteringMode: 1
+ m_PVRCulling: 1
+ m_PVRFilteringGaussRadiusDirect: 1
+ m_PVRFilteringGaussRadiusIndirect: 5
+ m_PVRFilteringGaussRadiusAO: 2
+ m_PVRFilteringAtrousPositionSigmaDirect: 0.5
+ m_PVRFilteringAtrousPositionSigmaIndirect: 2
+ m_PVRFilteringAtrousPositionSigmaAO: 1
+ m_ShowResolutionOverlay: 1
+ m_LightingDataAsset: {fileID: 0}
+ m_UseShadowmask: 1
+--- !u!196 &4
+NavMeshSettings:
+ serializedVersion: 2
+ m_ObjectHideFlags: 0
+ m_BuildSettings:
+ serializedVersion: 2
+ agentTypeID: 0
+ agentRadius: 0.5
+ agentHeight: 2
+ agentSlope: 45
+ agentClimb: 0.4
+ ledgeDropHeight: 0
+ maxJumpAcrossDistance: 0
+ minRegionArea: 2
+ manualCellSize: 0
+ cellSize: 0.16666667
+ manualTileSize: 0
+ tileSize: 256
+ accuratePlacement: 0
+ debug:
+ m_Flags: 0
+ m_NavMeshData: {fileID: 0}
+--- !u!1 &516737225
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 516737226}
+ - component: {fileID: 516737227}
+ m_Layer: 0
+ m_Name: Main
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &516737226
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 516737225}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &516737227
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 516737225}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: c1b55962346f6de40bd5e924df2854fb, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ url: ws://echo.websocket.org
+--- !u!1 &902376145
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 902376148}
+ - component: {fileID: 902376147}
+ - component: {fileID: 902376146}
+ m_Layer: 0
+ m_Name: Camera
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!81 &902376146
+AudioListener:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 902376145}
+ m_Enabled: 1
+--- !u!20 &902376147
+Camera:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 902376145}
+ m_Enabled: 1
+ serializedVersion: 2
+ m_ClearFlags: 2
+ m_BackGroundColor: {r: 0.3301887, g: 0.3301887, b: 0.3301887, a: 0}
+ m_projectionMatrixMode: 1
+ m_SensorSize: {x: 36, y: 24}
+ m_LensShift: {x: 0, y: 0}
+ m_GateFitMode: 2
+ m_FocalLength: 50
+ m_NormalizedViewPortRect:
+ serializedVersion: 2
+ x: 0
+ y: 0
+ width: 1
+ height: 1
+ near clip plane: 0.3
+ far clip plane: 1000
+ field of view: 60
+ orthographic: 0
+ orthographic size: 5
+ m_Depth: 0
+ m_CullingMask:
+ serializedVersion: 2
+ m_Bits: 4294967295
+ m_RenderingPath: -1
+ m_TargetTexture: {fileID: 0}
+ m_TargetDisplay: 0
+ m_TargetEye: 3
+ m_HDR: 1
+ m_AllowMSAA: 1
+ m_AllowDynamicResolution: 0
+ m_ForceIntoRT: 0
+ m_OcclusionCulling: 1
+ m_StereoConvergence: 10
+ m_StereoSeparation: 0.022
+--- !u!4 &902376148
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 902376145}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
diff --git a/Example/Example.unity.meta b/Example/Example.unity.meta
new file mode 100644
index 00000000..2a694d73
--- /dev/null
+++ b/Example/Example.unity.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: b9e0f303577eab04b8c94ba1bfe99d69
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Example/UnityWebSocket.Example.asmdef b/Example/UnityWebSocket.Example.asmdef
new file mode 100644
index 00000000..b7d0b3e0
--- /dev/null
+++ b/Example/UnityWebSocket.Example.asmdef
@@ -0,0 +1,14 @@
+{
+ "name": "UnityWebSocket.Example",
+ "references": [
+ "UnityWebSocket.Runtime"
+ ],
+ "optionalUnityReferences": [],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": []
+}
\ No newline at end of file
diff --git a/Example/UnityWebSocket.Example.asmdef.meta b/Example/UnityWebSocket.Example.asmdef.meta
new file mode 100644
index 00000000..18d62857
--- /dev/null
+++ b/Example/UnityWebSocket.Example.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: cddcf2ec2291b416eb85e8fdb077ce0d
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Plugins.meta b/Plugins.meta
new file mode 100644
index 00000000..820207ab
--- /dev/null
+++ b/Plugins.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 4589fa9979d007040b5a807b0304b1ff
+folderAsset: yes
+timeCreated: 1466577973
+licenseType: Pro
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Plugins/WebGL.meta b/Plugins/WebGL.meta
new file mode 100644
index 00000000..404a7f6b
--- /dev/null
+++ b/Plugins/WebGL.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f1a1a6aea65cc413faf8fb4421138b29
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Plugins/WebGL/WebSocket.jslib b/Plugins/WebGL/WebSocket.jslib
new file mode 100644
index 00000000..8a19945d
--- /dev/null
+++ b/Plugins/WebGL/WebSocket.jslib
@@ -0,0 +1,349 @@
+var WebSocketLibrary =
+{
+ $webSocketManager:
+ {
+ /*
+ * Map of instances
+ *
+ * Instance structure:
+ * {
+ * url: string,
+ * ws: WebSocket
+ * }
+ */
+ instances: {},
+
+ /* Last instance ID */
+ lastId: 0,
+
+ /* Event listeners */
+ onOpen: null,
+ onMesssage: null,
+ onError: null,
+ onClose: null,
+
+ /* Debug mode */
+ debug: false
+ },
+
+ /**
+ * Set onOpen callback
+ *
+ * @param callback Reference to C# static function
+ */
+ WebSocketSetOnOpen: function(callback)
+ {
+ webSocketManager.onOpen = callback;
+ },
+
+ /**
+ * Set onMessage callback
+ *
+ * @param callback Reference to C# static function
+ */
+ WebSocketSetOnMessage: function(callback)
+ {
+ webSocketManager.onMessage = callback;
+ },
+
+ /**
+ * Set onMessage callback
+ *
+ * @param callback Reference to C# static function
+ */
+ WebSocketSetOnMessageStr: function(callback)
+ {
+ webSocketManager.onMessageStr = callback;
+ },
+
+ /**
+ * Set onError callback
+ *
+ * @param callback Reference to C# static function
+ */
+ WebSocketSetOnError: function(callback)
+ {
+ webSocketManager.onError = callback;
+ },
+
+ /**
+ * Set onClose callback
+ *
+ * @param callback Reference to C# static function
+ */
+ WebSocketSetOnClose: function(callback)
+ {
+ webSocketManager.onClose = callback;
+ },
+
+ /**
+ * Allocate new WebSocket instance struct
+ *
+ * @param url Server URL
+ */
+ WebSocketAllocate: function(url)
+ {
+ var urlStr = Pointer_stringify(url);
+ var id = webSocketManager.lastId++;
+ webSocketManager.instances[id] = {
+ url: urlStr,
+ ws: null
+ };
+ return id;
+ },
+
+ /**
+ * Remove reference to WebSocket instance
+ *
+ * If socket is not closed function will close it but onClose event will not be emitted because
+ * this function should be invoked by C# WebSocket destructor.
+ *
+ * @param instanceId Instance ID
+ */
+ WebSocketFree: function(instanceId)
+ {
+ var instance = webSocketManager.instances[instanceId];
+ if (!instance) return 0;
+
+ // Close if not closed
+ if (instance.ws !== null && instance.ws.readyState < 2)
+ instance.ws.close();
+
+ // Remove reference
+ delete webSocketManager.instances[instanceId];
+
+ return 0;
+ },
+
+ /**
+ * Connect WebSocket to the server
+ *
+ * @param instanceId Instance ID
+ */
+ WebSocketConnect: function(instanceId)
+ {
+ var instance = webSocketManager.instances[instanceId];
+ if (!instance) return -1;
+
+ if (instance.ws !== null)
+ return -2;
+
+ instance.ws = new WebSocket(instance.url);
+
+ instance.ws.onopen = function()
+ {
+ if (webSocketManager.debug)
+ console.log("[JSLIB WebSocket] Connected.");
+ if (webSocketManager.onOpen)
+ Runtime.dynCall('vi', webSocketManager.onOpen, [ instanceId ]);
+ };
+
+ instance.ws.onmessage = function(ev)
+ {
+ if (webSocketManager.debug)
+ console.log("[JSLIB WebSocket] Received message: ", ev.data);
+
+ if (webSocketManager.onMessage === null)
+ return;
+
+ if (ev.data instanceof ArrayBuffer)
+ {
+ var dataBuffer = new Uint8Array(ev.data);
+ var buffer = _malloc(dataBuffer.length);
+ HEAPU8.set(dataBuffer, buffer);
+ try
+ {
+ Runtime.dynCall('viii', webSocketManager.onMessage, [ instanceId, buffer, dataBuffer.length ]);
+ }
+ finally
+ {
+ _free(buffer);
+ }
+ }
+ else if (ev.data instanceof Blob)
+ {
+ var reader = new FileReader();
+ reader.addEventListener("loadend", function()
+ {
+ var dataBuffer = new Uint8Array(reader.result);
+ var buffer = _malloc(dataBuffer.length);
+ HEAPU8.set(dataBuffer, buffer);
+ try
+ {
+ Runtime.dynCall('viii', webSocketManager.onMessage, [ instanceId, buffer, dataBuffer.length ]);
+ }
+ finally
+ {
+ reader = null;
+ _free(buffer);
+ }
+ });
+ reader.readAsArrayBuffer(ev.data);
+ }
+ else if(typeof ev.data == 'string')
+ {
+ var length = lengthBytesUTF8(ev.data) + 1;
+ var buffer = _malloc(length);
+ stringToUTF8(ev.data, buffer, length);
+ try
+ {
+ Runtime.dynCall('vii', webSocketManager.onMessageStr, [ instanceId, buffer ]);
+ }
+ finally
+ {
+ _free(buffer);
+ }
+ }
+ else
+ {
+ console.log("[JSLIB WebSocket] not support message type: ", (typeof ev.data));
+ }
+ };
+
+ instance.ws.onerror = function(ev)
+ {
+ if (webSocketManager.debug)
+ console.log("[JSLIB WebSocket] Error occured.");
+
+ if (webSocketManager.onError)
+ {
+ var msg = "WebSocket error.";
+ var length = lengthBytesUTF8(msg) + 1;
+ var buffer = _malloc(length);
+ stringToUTF8(msg, buffer, length);
+ try
+ {
+ Runtime.dynCall('vii', webSocketManager.onError, [ instanceId, buffer ]);
+ }
+ finally
+ {
+ _free(buffer);
+ }
+ }
+ };
+
+ instance.ws.onclose = function(ev)
+ {
+ if (webSocketManager.debug)
+ console.log("[JSLIB WebSocket] Closed, Code: " + ev.code + ", Reason: " + ev.reason);
+
+ if (webSocketManager.onClose)
+ {
+ var msg = ev.reason;
+ var length = lengthBytesUTF8(msg) + 1;
+ var buffer = _malloc(length);
+ stringToUTF8(msg, buffer, length);
+ try
+ {
+ Runtime.dynCall('viii', webSocketManager.onClose, [ instanceId, ev.code, buffer ]);
+ }
+ finally
+ {
+ _free(buffer);
+ }
+ }
+
+ instance.ws = null;
+ };
+ return 0;
+ },
+
+ /**
+ * Close WebSocket connection
+ *
+ * @param instanceId Instance ID
+ * @param code Close status code
+ * @param reasonPtr Pointer to reason string
+ */
+ WebSocketClose: function(instanceId, code, reasonPtr)
+ {
+ var instance = webSocketManager.instances[instanceId];
+ if (!instance) return -1;
+
+ if (instance.ws === null)
+ return -3;
+
+ if (instance.ws.readyState === 2)
+ return -4;
+
+ if (instance.ws.readyState === 3)
+ return -5;
+
+ var reason = ( reasonPtr ? Pointer_stringify(reasonPtr) : undefined );
+
+ try
+ {
+ instance.ws.close(code, reason);
+ }
+ catch(err)
+ {
+ return -7;
+ }
+
+ return 0;
+ },
+
+ /**
+ * Send message over WebSocket
+ *
+ * @param instanceId Instance ID
+ * @param bufferPtr Pointer to the message buffer
+ * @param length Length of the message in the buffer
+ */
+ WebSocketSend: function(instanceId, bufferPtr, length)
+ {
+ var instance = webSocketManager.instances[instanceId];
+ if (!instance) return -1;
+
+ if (instance.ws === null)
+ return -3;
+
+ if (instance.ws.readyState !== 1)
+ return -6;
+
+ instance.ws.send(HEAPU8.buffer.slice(bufferPtr, bufferPtr + length));
+
+ return 0;
+ },
+
+ /**
+ * Send message string over WebSocket
+ *
+ * @param instanceId Instance ID
+ * @param stringPtr Pointer to the message string
+ */
+ WebSocketSendStr: function(instanceId, stringPtr)
+ {
+ var instance = webSocketManager.instances[instanceId];
+ if (!instance) return -1;
+
+ if (instance.ws === null)
+ return -3;
+
+ if (instance.ws.readyState !== 1)
+ return -6;
+
+ instance.ws.send(Pointer_stringify(stringPtr));
+
+ return 0;
+ },
+
+ /**
+ * Return WebSocket readyState
+ *
+ * @param instanceId Instance ID
+ */
+ WebSocketGetState: function(instanceId)
+ {
+ var instance = webSocketManager.instances[instanceId];
+ if (!instance) return -1;
+
+ if (instance.ws)
+ return instance.ws.readyState;
+ else
+ return 3;
+ }
+};
+
+autoAddDeps(WebSocketLibrary, '$webSocketManager');
+mergeInto(LibraryManager.library, WebSocketLibrary);
diff --git a/Plugins/WebGL/WebSocket.jslib.meta b/Plugins/WebGL/WebSocket.jslib.meta
new file mode 100644
index 00000000..47574dd1
--- /dev/null
+++ b/Plugins/WebGL/WebSocket.jslib.meta
@@ -0,0 +1,37 @@
+fileFormatVersion: 2
+guid: bd88770aa13fc47b08f87d2145e9ac6e
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ Facebook: WebGL
+ second:
+ enabled: 1
+ settings: {}
+ - first:
+ WebGL: WebGL
+ second:
+ enabled: 1
+ settings: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime.meta b/Runtime.meta
new file mode 100644
index 00000000..497f84bf
--- /dev/null
+++ b/Runtime.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 53e0ed9fdc3af42eba12a5b1b9a5f873
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core.meta b/Runtime/Core.meta
new file mode 100644
index 00000000..75a53494
--- /dev/null
+++ b/Runtime/Core.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 8b3a2a8f55d4a47f599b1fa3ed612389
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/CloseEventArgs.cs b/Runtime/Core/CloseEventArgs.cs
new file mode 100644
index 00000000..d0d5831a
--- /dev/null
+++ b/Runtime/Core/CloseEventArgs.cs
@@ -0,0 +1,89 @@
+using System;
+
+namespace UnityWebSocket
+{
+ ///
+ /// Represents the event data for the event.
+ ///
+ ///
+ ///
+ /// That event occurs when the WebSocket connection has been closed.
+ ///
+ ///
+ /// If you would like to get the reason for the close, you should access
+ /// the or property.
+ ///
+ ///
+ public class CloseEventArgs : EventArgs
+ {
+ #region Internal Constructors
+
+ internal CloseEventArgs()
+ {
+ }
+
+ internal CloseEventArgs(ushort code)
+ : this(code, null)
+ {
+ }
+
+ internal CloseEventArgs(CloseStatusCode code)
+ : this((ushort)code, null)
+ {
+ }
+
+ internal CloseEventArgs(CloseStatusCode code, string reason)
+ : this((ushort)code, reason)
+ {
+ }
+
+ internal CloseEventArgs(ushort code, string reason)
+ {
+ Code = code;
+ Reason = reason;
+ }
+
+ #endregion
+
+ #region Public Properties
+
+ ///
+ /// Gets the status code for the close.
+ ///
+ ///
+ /// A that represents the status code for the close if any.
+ ///
+ public ushort Code { get; private set; }
+
+ ///
+ /// Gets the reason for the close.
+ ///
+ ///
+ /// A that represents the reason for the close if any.
+ ///
+ public string Reason { get; private set; }
+
+ ///
+ /// Gets a value indicating whether the connection has been closed cleanly.
+ ///
+ ///
+ /// true if the connection has been closed cleanly; otherwise, false.
+ ///
+ public bool WasClean { get; internal set; }
+
+ ///
+ /// Enum value same as Code
+ ///
+ public CloseStatusCode StatusCode
+ {
+ get
+ {
+ if (Enum.IsDefined(typeof(CloseStatusCode), Code))
+ return (CloseStatusCode)Code;
+ return CloseStatusCode.Unknown;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Runtime/Core/CloseEventArgs.cs.meta b/Runtime/Core/CloseEventArgs.cs.meta
new file mode 100644
index 00000000..6e2a928a
--- /dev/null
+++ b/Runtime/Core/CloseEventArgs.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 29b987d07ba15434cb1744135a7a5416
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/CloseStatusCode.cs b/Runtime/Core/CloseStatusCode.cs
new file mode 100644
index 00000000..0da2ddbd
--- /dev/null
+++ b/Runtime/Core/CloseStatusCode.cs
@@ -0,0 +1,91 @@
+namespace UnityWebSocket
+{
+ ///
+ /// Indicates the status code for the WebSocket connection close.
+ ///
+ ///
+ ///
+ /// The values of this enumeration are defined in
+ ///
+ /// Section 7.4 of RFC 6455.
+ ///
+ ///
+ /// "Reserved value" cannot be sent as a status code in
+ /// closing handshake by an endpoint.
+ ///
+ ///
+ public enum CloseStatusCode : ushort
+ {
+ Unknown = 65534,
+ ///
+ /// Equivalent to close status 1000. Indicates normal close.
+ ///
+ Normal = 1000,
+ ///
+ /// Equivalent to close status 1001. Indicates that an endpoint is
+ /// going away.
+ ///
+ Away = 1001,
+ ///
+ /// Equivalent to close status 1002. Indicates that an endpoint is
+ /// terminating the connection due to a protocol error.
+ ///
+ ProtocolError = 1002,
+ ///
+ /// Equivalent to close status 1003. Indicates that an endpoint is
+ /// terminating the connection because it has received a type of
+ /// data that it cannot accept.
+ ///
+ UnsupportedData = 1003,
+ ///
+ /// Equivalent to close status 1004. Still undefined. A Reserved value.
+ ///
+ Undefined = 1004,
+ ///
+ /// Equivalent to close status 1005. Indicates that no status code was
+ /// actually present. A Reserved value.
+ ///
+ NoStatus = 1005,
+ ///
+ /// Equivalent to close status 1006. Indicates that the connection was
+ /// closed abnormally. A Reserved value.
+ ///
+ Abnormal = 1006,
+ ///
+ /// Equivalent to close status 1007. Indicates that an endpoint is
+ /// terminating the connection because it has received a message that
+ /// contains data that is not consistent with the type of the message.
+ ///
+ InvalidData = 1007,
+ ///
+ /// Equivalent to close status 1008. Indicates that an endpoint is
+ /// terminating the connection because it has received a message that
+ /// violates its policy.
+ ///
+ PolicyViolation = 1008,
+ ///
+ /// Equivalent to close status 1009. Indicates that an endpoint is
+ /// terminating the connection because it has received a message that
+ /// is too big to process.
+ ///
+ TooBig = 1009,
+ ///
+ /// Equivalent to close status 1010. Indicates that a client is
+ /// terminating the connection because it has expected the server to
+ /// negotiate one or more extension, but the server did not return
+ /// them in the handshake response.
+ ///
+ MandatoryExtension = 1010,
+ ///
+ /// Equivalent to close status 1011. Indicates that a server is
+ /// terminating the connection because it has encountered an unexpected
+ /// condition that prevented it from fulfilling the request.
+ ///
+ ServerError = 1011,
+ ///
+ /// Equivalent to close status 1015. Indicates that the connection was
+ /// closed due to a failure to perform a TLS handshake. A Reserved value.
+ ///
+ TlsHandshakeFailure = 1015,
+ }
+}
diff --git a/Runtime/Core/CloseStatusCode.cs.meta b/Runtime/Core/CloseStatusCode.cs.meta
new file mode 100644
index 00000000..48e96605
--- /dev/null
+++ b/Runtime/Core/CloseStatusCode.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4e34ee317292e4225a10427cc35f85ec
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/ErrorEventArgs.cs b/Runtime/Core/ErrorEventArgs.cs
new file mode 100644
index 00000000..cfb91b87
--- /dev/null
+++ b/Runtime/Core/ErrorEventArgs.cs
@@ -0,0 +1,59 @@
+using System;
+
+namespace UnityWebSocket
+{
+ ///
+ /// Represents the event data for the event.
+ ///
+ ///
+ ///
+ /// That event occurs when the gets an error.
+ ///
+ ///
+ /// If you would like to get the error message, you should access
+ /// the property.
+ ///
+ ///
+ /// And if the error is due to an exception, you can get it by accessing
+ /// the property.
+ ///
+ ///
+ public class ErrorEventArgs : EventArgs
+ {
+ #region Internal Constructors
+
+ internal ErrorEventArgs(string message)
+ : this(message, null)
+ {
+ }
+
+ internal ErrorEventArgs(string message, Exception exception)
+ {
+ this.Message = message;
+ this.Exception = exception;
+ }
+
+ #endregion
+
+ #region Public Properties
+
+ ///
+ /// Gets the exception that caused the error.
+ ///
+ ///
+ /// An instance that represents the cause of
+ /// the error if it is due to an exception; otherwise, .
+ ///
+ public Exception Exception { get; private set; }
+
+ ///
+ /// Gets the error message.
+ ///
+ ///
+ /// A that represents the error message.
+ ///
+ public string Message { get; private set; }
+
+ #endregion
+ }
+}
diff --git a/Runtime/Core/ErrorEventArgs.cs.meta b/Runtime/Core/ErrorEventArgs.cs.meta
new file mode 100644
index 00000000..47a5055b
--- /dev/null
+++ b/Runtime/Core/ErrorEventArgs.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 884e7db60b6444154b7200e0e436f2de
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/IWebSocket.cs b/Runtime/Core/IWebSocket.cs
new file mode 100644
index 00000000..5e14219d
--- /dev/null
+++ b/Runtime/Core/IWebSocket.cs
@@ -0,0 +1,156 @@
+using System;
+
+namespace UnityWebSocket
+{
+ ///
+ /// IWebSocket indicate a network connection.
+ /// It can be connecting, connected, closing or closed state.
+ /// You can send and receive messages by using it.
+ /// Register onreceive callback for handling received messages.
+ /// -----------------------------------------------------------
+ /// IWebSocket 表示一个网络连接,
+ /// 它可以是 connecting connected closing closed 状态,
+ /// 可以发送和接收消息,
+ /// 通过注册消息回调,来处理接收到的消息。
+ ///
+ public interface IWebSocket
+ {
+ ///
+ /// Establishes a connection asynchronously.
+ ///
+ ///
+ ///
+ /// This method does not wait for the connect process to be complete.
+ ///
+ ///
+ /// This method does nothing if the connection has already been
+ /// established.
+ ///
+ ///
+ ///
+ ///
+ /// This instance is not a client.
+ ///
+ ///
+ /// -or-
+ ///
+ ///
+ /// The close process is in progress.
+ ///
+ ///
+ /// -or-
+ ///
+ ///
+ /// A series of reconnecting has failed.
+ ///
+ ///
+ void ConnectAsync();
+
+ ///
+ /// Closes the connection asynchronously.
+ ///
+ ///
+ ///
+ /// This method does not wait for the close to be complete.
+ ///
+ ///
+ /// This method does nothing if the current state of the connection is
+ /// Closing or Closed.
+ ///
+ ///
+ void CloseAsync();
+
+ ///
+ /// Sends the specified data asynchronously using the WebSocket connection.
+ ///
+ ///
+ /// This method does not wait for the send to be complete.
+ ///
+ ///
+ /// An array of that represents the binary data to send.
+ ///
+ ///
+ ///
+ /// An Action delegate or
+ /// if not needed.
+ ///
+ ///
+ /// The delegate invokes the method called when the send is complete.
+ ///
+ ///
+ ///
+ /// The current state of the connection is not Open.
+ ///
+ ///
+ /// is .
+ ///
+ void SendAsync(byte[] data, Action completed = null);
+
+ ///
+ /// Sends the specified data using the WebSocket connection.
+ ///
+ ///
+ /// A that represents the text data to send.
+ ///
+ ///
+ ///
+ /// An Action delegate or
+ /// if not needed.
+ ///
+ ///
+ /// The delegate invokes the method called when the send is complete.
+ ///
+ ///
+ ///
+ /// The current state of the connection is not Open.
+ ///
+ ///
+ /// is .
+ ///
+ ///
+ /// could be UTF-8 encoded.
+ ///
+ void SendAsync(string text, Action completed = null);
+
+ ///
+ /// get the address which to connect.
+ ///
+ string Address { get; }
+
+ ///
+ /// Gets the current state of the connection.
+ ///
+ ///
+ ///
+ /// One of the enum values.
+ ///
+ ///
+ /// It indicates the current state of the connection.
+ ///
+ ///
+ /// The default value is .
+ ///
+ ///
+ WebSocketState ReadyState { get; }
+
+ ///
+ /// Occurs when the WebSocket connection has been established.
+ ///
+ event EventHandler OnOpen;
+
+ ///
+ /// Occurs when the WebSocket connection has been closed.
+ ///
+ event EventHandler OnClose;
+
+ ///
+ /// Occurs when the gets an error.
+ ///
+ event EventHandler OnError;
+
+ ///
+ /// Occurs when the receives a message.
+ ///
+ event EventHandler OnMessage;
+ }
+}
diff --git a/Runtime/Core/IWebSocket.cs.meta b/Runtime/Core/IWebSocket.cs.meta
new file mode 100644
index 00000000..ae658256
--- /dev/null
+++ b/Runtime/Core/IWebSocket.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 37ee2146eb8c34ffab8b081a632b05cf
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/MessageEventArgs.cs b/Runtime/Core/MessageEventArgs.cs
new file mode 100644
index 00000000..41fb5e59
--- /dev/null
+++ b/Runtime/Core/MessageEventArgs.cs
@@ -0,0 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace UnityWebSocket
+{
+ public class MessageEventArgs : EventArgs
+ {
+ private byte[] _rawData;
+ private string _data;
+
+ internal MessageEventArgs(Opcode opcode, byte[] rawData)
+ {
+ Opcode = opcode;
+ _rawData = rawData;
+ }
+
+ internal MessageEventArgs(Opcode opcode, string data)
+ {
+ Opcode = opcode;
+ _data = data;
+ }
+
+ ///
+ /// Gets the opcode for the message.
+ ///
+ ///
+ /// , ,
+ /// or .
+ ///
+ internal Opcode Opcode { get; private set; }
+
+ ///
+ /// Gets the message data as a .
+ ///
+ ///
+ /// A that represents the message data if its type is
+ /// text or ping and if decoding it to a string has successfully done;
+ /// otherwise, .
+ ///
+ public string Data
+ {
+ get
+ {
+ SetData();
+ return _data;
+ }
+ }
+
+ ///
+ /// Gets the message data as an array of .
+ ///
+ ///
+ /// An array of that represents the message data.
+ ///
+ public byte[] RawData
+ {
+ get
+ {
+ SetRawData();
+ return _rawData;
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the message type is binary.
+ ///
+ ///
+ /// true if the message type is binary; otherwise, false.
+ ///
+ public bool IsBinary
+ {
+ get
+ {
+ return Opcode == Opcode.Binary;
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the message type is ping.
+ ///
+ ///
+ /// true if the message type is ping; otherwise, false.
+ ///
+ public bool IsPing
+ {
+ get
+ {
+ return Opcode == Opcode.Ping;
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether the message type is text.
+ ///
+ ///
+ /// true if the message type is text; otherwise, false.
+ ///
+ public bool IsText
+ {
+ get
+ {
+ return Opcode == Opcode.Text;
+ }
+ }
+
+ private void SetData()
+ {
+ if (_data != null) return;
+
+ if (RawData == null)
+ {
+ return;
+ }
+
+ _data = Encoding.UTF8.GetString(RawData);
+ }
+
+ private void SetRawData()
+ {
+ if (_rawData != null) return;
+
+ if (_data == null)
+ {
+ return;
+ }
+
+ _rawData = Encoding.UTF8.GetBytes(_data);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Core/MessageEventArgs.cs.meta b/Runtime/Core/MessageEventArgs.cs.meta
new file mode 100644
index 00000000..1c3a7d13
--- /dev/null
+++ b/Runtime/Core/MessageEventArgs.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b44eda173b4924081bab76ae9d1b0a9c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/Opcode.cs b/Runtime/Core/Opcode.cs
new file mode 100644
index 00000000..1bd25b40
--- /dev/null
+++ b/Runtime/Core/Opcode.cs
@@ -0,0 +1,38 @@
+namespace UnityWebSocket
+{
+ ///
+ /// Indicates the WebSocket frame type.
+ ///
+ ///
+ /// The values of this enumeration are defined in
+ ///
+ /// Section 5.2 of RFC 6455.
+ ///
+ public enum Opcode : byte
+ {
+ ///
+ /// Equivalent to numeric value 0. Indicates continuation frame.
+ ///
+ Cont = 0x0,
+ ///
+ /// Equivalent to numeric value 1. Indicates text frame.
+ ///
+ Text = 0x1,
+ ///
+ /// Equivalent to numeric value 2. Indicates binary frame.
+ ///
+ Binary = 0x2,
+ ///
+ /// Equivalent to numeric value 8. Indicates connection close frame.
+ ///
+ Close = 0x8,
+ ///
+ /// Equivalent to numeric value 9. Indicates ping frame.
+ ///
+ Ping = 0x9,
+ ///
+ /// Equivalent to numeric value 10. Indicates pong frame.
+ ///
+ Pong = 0xa
+ }
+}
diff --git a/Runtime/Core/Opcode.cs.meta b/Runtime/Core/Opcode.cs.meta
new file mode 100644
index 00000000..a7ed802f
--- /dev/null
+++ b/Runtime/Core/Opcode.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: eeac0ef90273544ebbae046672caf362
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/OpenEventArgs.cs b/Runtime/Core/OpenEventArgs.cs
new file mode 100644
index 00000000..fa84a33d
--- /dev/null
+++ b/Runtime/Core/OpenEventArgs.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace UnityWebSocket
+{
+ public class OpenEventArgs : EventArgs
+ {
+ internal OpenEventArgs()
+ {
+ }
+ }
+}
diff --git a/Runtime/Core/OpenEventArgs.cs.meta b/Runtime/Core/OpenEventArgs.cs.meta
new file mode 100644
index 00000000..0cfe2c2d
--- /dev/null
+++ b/Runtime/Core/OpenEventArgs.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5fb6fd704bd4e4b8ba63cd0b28712955
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/Settings.cs b/Runtime/Core/Settings.cs
new file mode 100644
index 00000000..cd4eef35
--- /dev/null
+++ b/Runtime/Core/Settings.cs
@@ -0,0 +1,11 @@
+namespace UnityWebSocket
+{
+ public static class Settings
+ {
+ public const string GITHUB = "https://github.com/psygame/UnityWebSocket";
+ public const string QQ = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
+ public const string EMAIL = "799329256@qq.com";
+ public const string AUHTOR = "psygame";
+ public const string VERSION = "2.1.0";
+ }
+}
diff --git a/Runtime/Core/Settings.cs.meta b/Runtime/Core/Settings.cs.meta
new file mode 100644
index 00000000..c4220346
--- /dev/null
+++ b/Runtime/Core/Settings.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4c35c50cb0dc64d9bb451df7d80d80e2
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Core/WebSocketState.cs b/Runtime/Core/WebSocketState.cs
new file mode 100644
index 00000000..796ab15f
--- /dev/null
+++ b/Runtime/Core/WebSocketState.cs
@@ -0,0 +1,36 @@
+namespace UnityWebSocket
+{
+ ///
+ /// Reference html5 WebSocket ReadyState Properties
+ /// Indicates the state of a WebSocket connection.
+ ///
+ ///
+ /// The values of this enumeration are defined in
+ ///
+ /// The WebSocket API.
+ ///
+ public enum WebSocketState : ushort
+ {
+ ///
+ /// Equivalent to numeric value 0. Indicates that the connection has not
+ /// yet been established.
+ ///
+ Connecting = 0,
+ ///
+ /// Equivalent to numeric value 1. Indicates that the connection has
+ /// been established, and the communication is possible.
+ ///
+ Open = 1,
+ ///
+ /// Equivalent to numeric value 2. Indicates that the connection is
+ /// going through the closing handshake, or the close method has
+ /// been invoked.
+ ///
+ Closing = 2,
+ ///
+ /// Equivalent to numeric value 3. Indicates that the connection has
+ /// been closed or could not be established.
+ ///
+ Closed = 3
+ }
+}
diff --git a/Runtime/Core/WebSocketState.cs.meta b/Runtime/Core/WebSocketState.cs.meta
new file mode 100644
index 00000000..94877ec5
--- /dev/null
+++ b/Runtime/Core/WebSocketState.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5f6567ad13cb147a59f8af784f1c5f60
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation.meta b/Runtime/Implementation.meta
new file mode 100644
index 00000000..abb1981f
--- /dev/null
+++ b/Runtime/Implementation.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 396c66b333d624d539153070900bb73b
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/NoWebGL.meta b/Runtime/Implementation/NoWebGL.meta
new file mode 100644
index 00000000..0255b6cc
--- /dev/null
+++ b/Runtime/Implementation/NoWebGL.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b44a962917796448ab18d4cbc1dbb963
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/NoWebGL/WebSocket.cs b/Runtime/Implementation/NoWebGL/WebSocket.cs
new file mode 100644
index 00000000..67528e7f
--- /dev/null
+++ b/Runtime/Implementation/NoWebGL/WebSocket.cs
@@ -0,0 +1,401 @@
+#if !NET_LEGACY
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Net.WebSockets;
+
+
+namespace UnityWebSocket.NoWebGL
+{
+ public class WebSocket : IWebSocket
+ {
+ public string Address { get; private set; }
+
+ public WebSocketState ReadyState
+ {
+ get
+ {
+ if (socket == null)
+ return WebSocketState.Closed;
+ switch (socket.State)
+ {
+ case System.Net.WebSockets.WebSocketState.Closed:
+ case System.Net.WebSockets.WebSocketState.None:
+ return WebSocketState.Closed;
+ case System.Net.WebSockets.WebSocketState.CloseReceived:
+ case System.Net.WebSockets.WebSocketState.CloseSent:
+ return WebSocketState.Closing;
+ case System.Net.WebSockets.WebSocketState.Connecting:
+ return WebSocketState.Connecting;
+ case System.Net.WebSockets.WebSocketState.Open:
+ return WebSocketState.Open;
+ }
+ return WebSocketState.Closed;
+ }
+ }
+
+ public event EventHandler OnOpen;
+ public event EventHandler OnClose;
+ public event EventHandler OnError;
+ public event EventHandler OnMessage;
+
+ private ClientWebSocket socket;
+ private CancellationTokenSource cts;
+ private bool IsCtsCancel { get { return cts == null || cts.IsCancellationRequested; } }
+ private bool isSendThreadRunning;
+ private bool isReceiveThreadRunning;
+
+ public WebSocket(string address)
+ {
+ this.Address = address;
+ }
+
+ public void ConnectAsync()
+ {
+ if (cts != null || socket != null)
+ {
+ HandleError(new Exception("socket is busy."));
+ return;
+ }
+ cts = new CancellationTokenSource();
+ socket = new ClientWebSocket();
+ Task.Run(ConnectThread);
+ }
+
+ public void CloseAsync()
+ {
+ Task.Run(CloseThread);
+ }
+
+ public void SendAsync(byte[] data, Action completed = null)
+ {
+ var sendBuffer = SpawnBuffer(WebSocketMessageType.Binary, data, completed);
+ PushBuffer(sendBuffer);
+ }
+
+ public void SendAsync(string text, Action completed = null)
+ {
+ var data = Encoding.UTF8.GetBytes(text);
+ var sendBuffer = SpawnBuffer(WebSocketMessageType.Text, data, completed);
+ PushBuffer(sendBuffer);
+ }
+
+ private async Task ConnectThread()
+ {
+ // UnityEngine.Debug.Log("Connect Thread Start ...");
+
+ try
+ {
+ var uri = new Uri(Address);
+ await socket.ConnectAsync(uri, cts.Token);
+ }
+ catch (Exception e)
+ {
+ HandleError(e);
+ HandleClose((ushort)CloseStatusCode.Abnormal, e.Message);
+ SocketDispose();
+ return;
+ }
+
+ LongRunningTask(SendThread);
+ LongRunningTask(ReceiveThread);
+
+ HandleOpen();
+
+ // UnityEngine.Debug.Log("Connect Thread Stop !");
+ }
+
+ private async void CloseThread()
+ {
+ // UnityEngine.Debug.Log("Close Thread Start ...");
+
+ try
+ {
+ await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Normal Closure", cts.Token);
+ }
+ catch { }
+
+ // UnityEngine.Debug.Log("Close Thread Stop !");
+ }
+
+ private async void DisposeThread()
+ {
+ // UnityEngine.Debug.Log("Dispose Thread Start ...");
+
+ while (!IsCtsCancel || isSendThreadRunning || isReceiveThreadRunning)
+ {
+ await Task.Delay(1);
+ }
+
+ SocketDispose();
+
+ // UnityEngine.Debug.Log("Dispose Thread Stop !");
+ }
+
+ private async Task SendThread()
+ {
+ // UnityEngine.Debug.Log("Send Thread Start ...");
+
+ try
+ {
+ isSendThreadRunning = true;
+ SendBuffer buffer = null;
+ while (!IsCtsCancel)
+ {
+ if (sendBuffers.Count <= 0)
+ {
+ await Task.Delay(1);
+ continue;
+ }
+ buffer = PopBuffer();
+ if (!IsCtsCancel)
+ {
+ await socket.SendAsync(buffer.buffer, buffer.type, true, cts.Token);
+ HandleSent(buffer.callback);
+ }
+ ReleaseBuffer(buffer);
+
+ // UnityEngine.Debug.Log("SendBuffers: " + sendBuffers.Count + ", PoolelBuffers: " + pooledSendBuffers.Count);
+ }
+ }
+ catch (Exception e)
+ {
+ HandleError(e);
+ }
+ finally
+ {
+ isSendThreadRunning = false;
+ while (sendBuffers.Count > 0)
+ {
+ ReleaseBuffer(PopBuffer());
+ }
+ }
+
+ // UnityEngine.Debug.Log("Send Thread Stop !");
+ }
+
+ private async Task ReceiveThread()
+ {
+ // UnityEngine.Debug.Log("Receive Thread Start ...");
+
+ var bufferCap = 1024;
+ var buffer = new byte[bufferCap];
+ var received = 0;
+
+ string closeReason = "";
+ ushort closeCode = 0;
+ bool isClosed = false;
+
+ try
+ {
+ isReceiveThreadRunning = true;
+ var segment = new ArraySegment(buffer);
+
+ while (!IsCtsCancel && !isClosed)
+ {
+ WebSocketReceiveResult result = await socket.ReceiveAsync(segment, cts.Token);
+ received += result.Count;
+
+ if (received >= buffer.Length && !result.EndOfMessage)
+ {
+ bufferCap = bufferCap * 2;
+ var newBuffer = new byte[bufferCap];
+ Array.Copy(buffer, newBuffer, buffer.Length);
+ buffer = newBuffer;
+ newBuffer = null;
+ // UnityEngine.Debug.Log("Expand Receive Buffer to " + bufferCap);
+ }
+
+ if (!result.EndOfMessage)
+ {
+ segment = new ArraySegment(buffer, received, buffer.Length - received);
+ continue;
+ }
+
+ byte[] data = new byte[received];
+ for (int i = 0; i < received; i++)
+ {
+ data[i] = buffer[i];
+ }
+
+ switch (result.MessageType)
+ {
+ case WebSocketMessageType.Binary:
+ HandleMessage(Opcode.Binary, data);
+ break;
+ case WebSocketMessageType.Text:
+ HandleMessage(Opcode.Text, data);
+ break;
+ case WebSocketMessageType.Close:
+ isClosed = true;
+ closeCode = (ushort)result.CloseStatus;
+ closeReason = result.CloseStatusDescription;
+ break;
+ }
+ received = 0;
+ segment = new ArraySegment(buffer);
+ }
+ }
+ catch (Exception e)
+ {
+ HandleError(e);
+ closeCode = (ushort)CloseStatusCode.Abnormal;
+ closeReason = e.Message;
+ }
+ finally
+ {
+ isReceiveThreadRunning = false;
+ buffer = null;
+ }
+
+ cts.Cancel();
+ await Task.Run(DisposeThread);
+ HandleClose(closeCode, closeReason);
+
+ // UnityEngine.Debug.Log("Receive Thread Stop !");
+ }
+
+ private void LongRunningTask(Func function)
+ {
+ Task.Factory.StartNew(function, cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
+ }
+
+ private void SocketDispose()
+ {
+ cts.Dispose();
+ socket.Dispose();
+ cts = null;
+ socket = null;
+ }
+
+ private readonly Queue sendBuffers = new Queue();
+ private readonly Queue pooledSendBuffers = new Queue();
+
+ class SendBuffer
+ {
+ public WebSocketMessageType type;
+ public ArraySegment buffer;
+ public Action callback;
+ }
+
+ private void PushBuffer(SendBuffer sendBuffer)
+ {
+ lock (sendBuffers)
+ {
+ sendBuffers.Enqueue(sendBuffer);
+ }
+ }
+
+ private SendBuffer PopBuffer()
+ {
+ SendBuffer buffer;
+ lock (sendBuffers)
+ {
+ buffer = sendBuffers.Dequeue();
+ }
+ return buffer;
+ }
+
+ private void ReleaseBuffer(SendBuffer sendBuffer)
+ {
+ sendBuffer.buffer = default;
+ sendBuffer.callback = null;
+ lock (pooledSendBuffers)
+ {
+ pooledSendBuffers.Enqueue(sendBuffer);
+ }
+ }
+
+ private SendBuffer SpawnBuffer(WebSocketMessageType type, byte[] bytes, Action callback)
+ {
+ SendBuffer sendBuffer = null;
+ if (pooledSendBuffers.Count <= 0)
+ {
+ sendBuffer = new SendBuffer
+ {
+ type = WebSocketMessageType.Text,
+ buffer = new ArraySegment(bytes),
+ callback = callback
+ };
+ return sendBuffer;
+ }
+
+ lock (pooledSendBuffers)
+ {
+ sendBuffer = pooledSendBuffers.Dequeue();
+ }
+
+ sendBuffer.type = type;
+ sendBuffer.buffer = new ArraySegment(bytes);
+ sendBuffer.callback = callback;
+
+ return sendBuffer;
+ }
+
+ private void HandleOpen()
+ {
+ // UnityEngine.Debug.Log("OnOpen");
+
+ try
+ {
+ OnOpen?.Invoke(this, new OpenEventArgs());
+ }
+ catch (Exception e)
+ {
+ HandleError(e);
+ }
+ }
+
+ private void HandleSent(Action action)
+ {
+ // UnityEngine.Debug.Log("OnOpen");
+
+ try
+ {
+ action?.Invoke();
+ }
+ catch (Exception e)
+ {
+ HandleError(e);
+ }
+ }
+
+ private void HandleMessage(Opcode opcode, byte[] rawData)
+ {
+ // UnityEngine.Debug.Log("OnMessage: " + opcode);
+
+ try
+ {
+ OnMessage?.Invoke(this, new MessageEventArgs(opcode, rawData));
+ }
+ catch (Exception e)
+ {
+ HandleError(e);
+ }
+ }
+
+ private void HandleClose(ushort code, string reason)
+ {
+ // UnityEngine.Debug.Log("OnClose: " + code + " " + reason);
+
+ try
+ {
+ OnClose?.Invoke(this, new CloseEventArgs(code, reason));
+ }
+ catch (Exception e)
+ {
+ HandleError(e);
+ }
+ }
+
+ private void HandleError(Exception exception)
+ {
+ // UnityEngine.Debug.Log("OnError: " + exception.Message);
+
+ OnError?.Invoke(this, new ErrorEventArgs(exception.Message));
+ }
+ }
+}
+#endif
diff --git a/Runtime/Implementation/NoWebGL/WebSocket.cs.meta b/Runtime/Implementation/NoWebGL/WebSocket.cs.meta
new file mode 100644
index 00000000..cbb5e53a
--- /dev/null
+++ b/Runtime/Implementation/NoWebGL/WebSocket.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d10f88a23641b4beb8df74460fb7f705
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/Synchronized.meta b/Runtime/Implementation/Synchronized.meta
new file mode 100644
index 00000000..b5d4c0b8
--- /dev/null
+++ b/Runtime/Implementation/Synchronized.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 04c4003c883a645adb7276f30b091685
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/Synchronized/WebSocket.cs b/Runtime/Implementation/Synchronized/WebSocket.cs
new file mode 100644
index 00000000..5aa4fa2a
--- /dev/null
+++ b/Runtime/Implementation/Synchronized/WebSocket.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+
+namespace UnityWebSocket
+{
+ public class WebSocket : IWebSocket
+ {
+ public event EventHandler OnOpen;
+ public event EventHandler OnClose;
+ public event EventHandler OnError;
+ public event EventHandler OnMessage;
+ public string Address { get { return _socket.Address; } }
+ public WebSocketState ReadyState { get { return _socket.ReadyState; } }
+
+ private readonly Uniform.WebSocket _socket;
+
+ public WebSocket(string address)
+ {
+ _socket = new Uniform.WebSocket(address);
+
+ _socket.OnOpen += (o, e) =>
+ {
+ lock (eventArgsQueue) { eventArgsQueue.Enqueue(e); }
+ };
+ _socket.OnClose += (o, e) =>
+ {
+ lock (eventArgsQueue) { eventArgsQueue.Enqueue(e); }
+ };
+ _socket.OnError += (o, e) =>
+ {
+ lock (eventArgsQueue) { eventArgsQueue.Enqueue(e); }
+ };
+ _socket.OnMessage += (o, e) =>
+ {
+ lock (eventArgsQueue) { eventArgsQueue.Enqueue(e); }
+ };
+
+ WebSocketManager.Instance.Add(this);
+ }
+
+ public void SendAsync(string data, Action completed = null)
+ {
+ if (completed != null)
+ {
+ _socket.SendAsync(data, () =>
+ {
+ lock (sendCallbackQueue)
+ {
+ sendCallbackQueue.Enqueue(completed);
+ }
+ });
+ }
+ else
+ {
+ _socket.SendAsync(data);
+ }
+ }
+
+ public void SendAsync(byte[] data, Action completed = null)
+ {
+ if (completed != null)
+ {
+ _socket.SendAsync(data, () =>
+ {
+ lock (sendCallbackQueue)
+ {
+ sendCallbackQueue.Enqueue(completed);
+ }
+ });
+ }
+ else
+ {
+ _socket.SendAsync(data);
+ }
+ }
+
+ public void ConnectAsync()
+ {
+ _socket.ConnectAsync();
+ }
+
+ public void CloseAsync()
+ {
+ _socket.CloseAsync();
+ }
+
+ private readonly Queue eventArgsQueue = new Queue();
+ private readonly Queue sendCallbackQueue = new Queue();
+ public void Update()
+ {
+ while (sendCallbackQueue.Count > 0)
+ {
+ Action callback;
+ lock (sendCallbackQueue)
+ {
+ callback = sendCallbackQueue.Dequeue();
+ }
+ if (callback != null)
+ {
+ callback.Invoke();
+ }
+ }
+
+ while (eventArgsQueue.Count > 0)
+ {
+ EventArgs e;
+ lock (eventArgsQueue)
+ {
+ e = eventArgsQueue.Dequeue();
+ }
+
+ if (e is CloseEventArgs && OnClose != null)
+ {
+ OnClose.Invoke(this, e as CloseEventArgs);
+ }
+ else if (e is OpenEventArgs && OnOpen != null)
+ {
+ OnOpen.Invoke(this, e as OpenEventArgs);
+ }
+ else if (e is MessageEventArgs && OnMessage != null)
+ {
+ OnMessage.Invoke(this, e as MessageEventArgs);
+ }
+ else if (e is ErrorEventArgs && OnError != null)
+ {
+ OnError.Invoke(this, e as ErrorEventArgs);
+ }
+ }
+ }
+ }
+}
diff --git a/Runtime/Implementation/Synchronized/WebSocket.cs.meta b/Runtime/Implementation/Synchronized/WebSocket.cs.meta
new file mode 100644
index 00000000..1d901d0c
--- /dev/null
+++ b/Runtime/Implementation/Synchronized/WebSocket.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1d73728c3dddc4405a7db54c2abce389
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/Synchronized/WebSocketManager.cs b/Runtime/Implementation/Synchronized/WebSocketManager.cs
new file mode 100644
index 00000000..9a40a437
--- /dev/null
+++ b/Runtime/Implementation/Synchronized/WebSocketManager.cs
@@ -0,0 +1,65 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace UnityWebSocket
+{
+ internal class WebSocketManager : MonoBehaviour
+ {
+ private const string rootName = "[UnityWebSocketManager]";
+ private static WebSocketManager _instance;
+ public static WebSocketManager Instance
+ {
+ get
+ {
+ if (_instance == null)
+ AutoCreateInstance();
+ return _instance;
+ }
+ }
+
+ internal WebSocketManager()
+ { }
+
+
+ void Awake()
+ {
+ DontDestroyOnLoad(gameObject);
+ _instance = this;
+ }
+
+
+ public static void AutoCreateInstance()
+ {
+ GameObject go = GameObject.Find("/" + rootName);
+ if (go == null)
+ {
+ go = new GameObject(rootName);
+ }
+
+ if (go.GetComponent() == null)
+ {
+ go.AddComponent();
+ }
+ }
+
+ private readonly List sockets = new List();
+
+ public void Add(WebSocket socket)
+ {
+ sockets.Add(socket);
+ }
+
+ public void Remove(WebSocket socket)
+ {
+ sockets.Remove(socket);
+ }
+
+ private void Update()
+ {
+ foreach (var ws in sockets)
+ {
+ ws.Update();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Implementation/Synchronized/WebSocketManager.cs.meta b/Runtime/Implementation/Synchronized/WebSocketManager.cs.meta
new file mode 100644
index 00000000..1e26dc8c
--- /dev/null
+++ b/Runtime/Implementation/Synchronized/WebSocketManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 99157fb5def394c83a9e5342036c92b0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/Uniform.meta b/Runtime/Implementation/Uniform.meta
new file mode 100644
index 00000000..271c3825
--- /dev/null
+++ b/Runtime/Implementation/Uniform.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 2091c1e49d5694afe9f7b1f686dc7a64
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/Uniform/WebSocket.cs b/Runtime/Implementation/Uniform/WebSocket.cs
new file mode 100644
index 00000000..75ed9663
--- /dev/null
+++ b/Runtime/Implementation/Uniform/WebSocket.cs
@@ -0,0 +1,72 @@
+using System;
+
+namespace UnityWebSocket.Uniform
+{
+ public class WebSocket : IWebSocket
+ {
+ #region Public Events
+ public event EventHandler OnOpen;
+ public event EventHandler OnClose;
+ public event EventHandler OnError;
+ public event EventHandler OnMessage;
+ #endregion
+
+ public string Address { get { return _rawSocket.Address; } }
+
+ public WebSocketState ReadyState { get { return _rawSocket.ReadyState; } }
+
+ private readonly IWebSocket _rawSocket;
+
+ public WebSocket(string address)
+ {
+#if !UNITY_EDITOR && UNITY_WEBGL
+ _rawSocket = new WebGL.WebSocket(address);
+#elif !NET_LEGACY
+ _rawSocket = new NoWebGL.WebSocket(address);
+#else
+ throw new Exception("Scripting Runtime Version should be .NET 4.x, via Menu:\nPlayerSettings -> Other Settings -> Script Runtime Version -> .Net 4.x Equivalent");
+#endif
+ _rawSocket.OnOpen += (o, e) =>
+ {
+ if (OnOpen != null)
+ OnOpen.Invoke(this, e);
+ };
+ _rawSocket.OnClose += (o, e) =>
+ {
+ if (OnClose != null)
+ OnClose.Invoke(this, e);
+ };
+ _rawSocket.OnError += (o, e) =>
+ {
+ if (OnError != null)
+ OnError.Invoke(this, e);
+ };
+ _rawSocket.OnMessage += (o, e) =>
+ {
+ if (OnMessage != null)
+ OnMessage.Invoke(this, e);
+ };
+ }
+
+
+ public void SendAsync(string data, Action completed = null)
+ {
+ _rawSocket.SendAsync(data, completed);
+ }
+
+ public void SendAsync(byte[] data, Action completed = null)
+ {
+ _rawSocket.SendAsync(data, completed);
+ }
+
+ public void ConnectAsync()
+ {
+ _rawSocket.ConnectAsync();
+ }
+
+ public void CloseAsync()
+ {
+ _rawSocket.CloseAsync();
+ }
+ }
+}
diff --git a/Runtime/Implementation/Uniform/WebSocket.cs.meta b/Runtime/Implementation/Uniform/WebSocket.cs.meta
new file mode 100644
index 00000000..a3240889
--- /dev/null
+++ b/Runtime/Implementation/Uniform/WebSocket.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5754364129b4a4c259981b11ddde4bd0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/WebGL.meta b/Runtime/Implementation/WebGL.meta
new file mode 100644
index 00000000..e9c4e7b5
--- /dev/null
+++ b/Runtime/Implementation/WebGL.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1fb37927ec1ce4def9c5e7cff883f9f5
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/WebGL/WebSocket.cs b/Runtime/Implementation/WebGL/WebSocket.cs
new file mode 100644
index 00000000..35473a9b
--- /dev/null
+++ b/Runtime/Implementation/WebGL/WebSocket.cs
@@ -0,0 +1,90 @@
+using System;
+
+namespace UnityWebSocket.WebGL
+{
+ public class WebSocket : IWebSocket
+ {
+ public string Address { get; private set; }
+ public WebSocketState ReadyState { get { return (WebSocketState)WebSocketManager.WebSocketGetState(instanceID); } }
+
+ public event EventHandler OnOpen;
+ public event EventHandler OnClose;
+ public event EventHandler OnError;
+ public event EventHandler OnMessage;
+
+ private int instanceID;
+
+ public WebSocket(string address)
+ {
+ this.Address = address;
+ this.instanceID = WebSocketManager.Add(this);
+ }
+
+ ~WebSocket()
+ {
+ WebSocketManager.HandleInstanceDestroy(instanceID);
+ }
+
+ internal void HandleOnOpen()
+ {
+ if (OnOpen != null)
+ OnOpen.Invoke(this, new OpenEventArgs());
+ }
+
+ internal void HandleOnMessage(byte[] rawData)
+ {
+ if (OnMessage != null)
+ OnMessage.Invoke(this, new MessageEventArgs(Opcode.Binary, rawData));
+ }
+
+ internal void HandleOnMessageStr(string data)
+ {
+ if (OnMessage != null)
+ OnMessage.Invoke(this, new MessageEventArgs(Opcode.Text, data));
+ }
+
+ internal void HandleOnClose(ushort code, string reason)
+ {
+ if (OnClose != null)
+ OnClose.Invoke(this, new CloseEventArgs(code, reason));
+ }
+
+ internal void HandleOnError(string msg)
+ {
+ if (OnError != null)
+ OnError.Invoke(this, new ErrorEventArgs(msg));
+ }
+
+ public void ConnectAsync()
+ {
+ int ret = WebSocketManager.WebSocketConnect(instanceID);
+ if (ret < 0)
+ HandleOnError(WebSocketManager.GetErrorMessageFromCode(ret));
+ }
+
+ public void CloseAsync()
+ {
+ int ret = WebSocketManager.WebSocketClose(instanceID, (int)CloseStatusCode.Normal, "Normal Closure");
+ if (ret < 0)
+ HandleOnError(WebSocketManager.GetErrorMessageFromCode(ret));
+ }
+
+ public void SendAsync(string text, Action completed = null)
+ {
+ int ret = WebSocketManager.WebSocketSendStr(instanceID, text);
+ if (ret < 0)
+ HandleOnError(WebSocketManager.GetErrorMessageFromCode(ret));
+ if (completed != null)
+ completed.Invoke();
+ }
+
+ public void SendAsync(byte[] data, Action completed = null)
+ {
+ int ret = WebSocketManager.WebSocketSend(instanceID, data, data.Length);
+ if (ret < 0)
+ HandleOnError(WebSocketManager.GetErrorMessageFromCode(ret));
+ if (completed != null)
+ completed.Invoke();
+ }
+ }
+}
diff --git a/Runtime/Implementation/WebGL/WebSocket.cs.meta b/Runtime/Implementation/WebGL/WebSocket.cs.meta
new file mode 100644
index 00000000..ffe47c74
--- /dev/null
+++ b/Runtime/Implementation/WebGL/WebSocket.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 74a5b3c22251243d2a2f33e74741559d
+timeCreated: 1466578513
+licenseType: Pro
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Implementation/WebGL/WebSocketManager.cs b/Runtime/Implementation/WebGL/WebSocketManager.cs
new file mode 100644
index 00000000..be79e923
--- /dev/null
+++ b/Runtime/Implementation/WebGL/WebSocketManager.cs
@@ -0,0 +1,172 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using AOT;
+
+namespace UnityWebSocket.WebGL
+{
+ ///
+ /// Class providing static access methods to work with JSLIB WebSocket
+ ///
+ internal static class WebSocketManager
+ {
+ /* Map of websocket instances */
+ private static Dictionary instances = new Dictionary();
+
+ /* Delegates */
+ public delegate void OnOpenCallback(int instanceId);
+ public delegate void OnMessageCallback(int instanceId, IntPtr msgPtr, int msgSize);
+ public delegate void OnMessageStrCallback(int instanceId, IntPtr msgStrPtr);
+ public delegate void OnErrorCallback(int instanceId, IntPtr errorPtr);
+ public delegate void OnCloseCallback(int instanceId, int closeCode, IntPtr reasonPtr);
+
+ /* WebSocket JSLIB functions */
+ [DllImport("__Internal")]
+ public static extern int WebSocketConnect(int instanceId);
+
+ [DllImport("__Internal")]
+ public static extern int WebSocketClose(int instanceId, int code, string reason);
+
+ [DllImport("__Internal")]
+ public static extern int WebSocketSend(int instanceId, byte[] dataPtr, int dataLength);
+
+ [DllImport("__Internal")]
+ public static extern int WebSocketSendStr(int instanceId, string dataPtr);
+
+ [DllImport("__Internal")]
+ public static extern int WebSocketGetState(int instanceId);
+
+ /* WebSocket JSLIB callback setters and other functions */
+ [DllImport("__Internal")]
+ public static extern int WebSocketAllocate(string url);
+
+ [DllImport("__Internal")]
+ public static extern void WebSocketFree(int instanceId);
+
+ [DllImport("__Internal")]
+ public static extern void WebSocketSetOnOpen(OnOpenCallback callback);
+
+ [DllImport("__Internal")]
+ public static extern void WebSocketSetOnMessage(OnMessageCallback callback);
+
+ [DllImport("__Internal")]
+ public static extern void WebSocketSetOnMessageStr(OnMessageStrCallback callback);
+
+ [DllImport("__Internal")]
+ public static extern void WebSocketSetOnError(OnErrorCallback callback);
+
+ [DllImport("__Internal")]
+ public static extern void WebSocketSetOnClose(OnCloseCallback callback);
+
+ /* If callbacks was initialized and set */
+ private static bool isInitialized = false;
+
+ /* Initialize WebSocket callbacks to JSLIB */
+ private static void Initialize()
+ {
+ WebSocketSetOnOpen(DelegateOnOpenEvent);
+ WebSocketSetOnMessage(DelegateOnMessageEvent);
+ WebSocketSetOnMessageStr(DelegateOnMessageStrEvent);
+ WebSocketSetOnError(DelegateOnErrorEvent);
+ WebSocketSetOnClose(DelegateOnCloseEvent);
+
+ isInitialized = true;
+ }
+
+ ///
+ /// Called when instance is destroyed (by destructor)
+ /// Method removes instance from map and free it in JSLIB implementation
+ ///
+ /// Instance identifier.
+ public static void HandleInstanceDestroy(int instanceId)
+ {
+ instances.Remove(instanceId);
+ WebSocketFree(instanceId);
+ }
+
+ [MonoPInvokeCallback(typeof(OnOpenCallback))]
+ public static void DelegateOnOpenEvent(int instanceId)
+ {
+
+ WebSocket instanceRef;
+
+ if (instances.TryGetValue(instanceId, out instanceRef))
+ {
+ instanceRef.HandleOnOpen();
+ }
+
+ }
+
+ [MonoPInvokeCallback(typeof(OnMessageCallback))]
+ public static void DelegateOnMessageEvent(int instanceId, IntPtr msgPtr, int msgSize)
+ {
+ WebSocket instanceRef;
+ if (instances.TryGetValue(instanceId, out instanceRef))
+ {
+ var bytes = new byte[msgSize];
+ Marshal.Copy(msgPtr, bytes, 0, msgSize);
+ instanceRef.HandleOnMessage(bytes);
+ }
+ }
+
+
+ [MonoPInvokeCallback(typeof(OnMessageCallback))]
+ public static void DelegateOnMessageStrEvent(int instanceId, IntPtr msgStrPtr)
+ {
+ WebSocket instanceRef;
+ if (instances.TryGetValue(instanceId, out instanceRef))
+ {
+ string msgStr = Marshal.PtrToStringAuto(msgStrPtr);
+ instanceRef.HandleOnMessageStr(msgStr);
+ }
+ }
+
+ [MonoPInvokeCallback(typeof(OnErrorCallback))]
+ public static void DelegateOnErrorEvent(int instanceId, IntPtr errorPtr)
+ {
+ WebSocket instanceRef;
+ if (instances.TryGetValue(instanceId, out instanceRef))
+ {
+ string errorMsg = Marshal.PtrToStringAuto(errorPtr);
+ instanceRef.HandleOnError(errorMsg);
+ }
+ }
+
+ [MonoPInvokeCallback(typeof(OnCloseCallback))]
+ public static void DelegateOnCloseEvent(int instanceId, int closeCode, IntPtr reasonPtr)
+ {
+ WebSocket instanceRef;
+ if (instances.TryGetValue(instanceId, out instanceRef))
+ {
+ string reason = Marshal.PtrToStringAuto(reasonPtr);
+ instanceRef.HandleOnClose((ushort)closeCode, reason);
+ }
+ }
+
+ public static int Add(WebSocket socket)
+ {
+ if (!isInitialized)
+ Initialize();
+
+ int instanceId = WebSocketAllocate(socket.Address);
+ instances.Add(instanceId, socket);
+ return instanceId;
+ }
+
+ public static string GetErrorMessageFromCode(int errorCode)
+ {
+ switch (errorCode)
+ {
+
+ case -1: return "WebSocket instance not found.";
+ case -2: return "WebSocket is already connected or in connecting state.";
+ case -3: return "WebSocket is not connected.";
+ case -4: return "WebSocket is already closing.";
+ case -5: return "WebSocket is already closed.";
+ case -6: return "WebSocket is not in open state.";
+ case -7: return "Cannot close WebSocket. An invalid code was specified or reason is too long.";
+ default: return "Unknown error.";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Implementation/WebGL/WebSocketManager.cs.meta b/Runtime/Implementation/WebGL/WebSocketManager.cs.meta
new file mode 100644
index 00000000..d0a16fef
--- /dev/null
+++ b/Runtime/Implementation/WebGL/WebSocketManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 246cdc66a1e2047148371a8e56e17d3a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/UnityWebSocket.Runtime.asmdef b/Runtime/UnityWebSocket.Runtime.asmdef
new file mode 100644
index 00000000..1dd0e569
--- /dev/null
+++ b/Runtime/UnityWebSocket.Runtime.asmdef
@@ -0,0 +1,12 @@
+{
+ "name": "UnityWebSocket.Runtime",
+ "references": [],
+ "optionalUnityReferences": [],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": []
+}
\ No newline at end of file
diff --git a/Runtime/UnityWebSocket.Runtime.asmdef.meta b/Runtime/UnityWebSocket.Runtime.asmdef.meta
new file mode 100644
index 00000000..b25bd684
--- /dev/null
+++ b/Runtime/UnityWebSocket.Runtime.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 8b65d8710c3b04373a41cbf6b777ee65
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
From fff2f57ed0eff87009ba4ce4ef149a1cdecf861a Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 11:05:56 +0800
Subject: [PATCH 02/66] =?UTF-8?q?=E6=95=B4=E7=90=86=E9=A1=B9=E7=9B=AE=20fo?=
=?UTF-8?q?r=20ump?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Scripts.meta | 8 ++++++++
Editor.meta => Scripts/Editor.meta | 0
{Editor => Scripts/Editor}/Help.cs | 0
{Editor => Scripts/Editor}/Help.cs.meta | 0
{Editor => Scripts/Editor}/PlayerSettingChecker.cs | 0
{Editor => Scripts/Editor}/PlayerSettingChecker.cs.meta | 0
{Editor => Scripts/Editor}/UnityWebSocket.Editor.asmdef | 0
.../Editor}/UnityWebSocket.Editor.asmdef.meta | 0
{Editor => Scripts/Editor}/VersionChecker.cs | 0
{Editor => Scripts/Editor}/VersionChecker.cs.meta | 0
Runtime.meta => Scripts/Runtime.meta | 0
{Runtime => Scripts/Runtime}/Core.meta | 0
{Runtime => Scripts/Runtime}/Core/CloseEventArgs.cs | 0
{Runtime => Scripts/Runtime}/Core/CloseEventArgs.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/CloseStatusCode.cs | 0
{Runtime => Scripts/Runtime}/Core/CloseStatusCode.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/ErrorEventArgs.cs | 0
{Runtime => Scripts/Runtime}/Core/ErrorEventArgs.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/IWebSocket.cs | 0
{Runtime => Scripts/Runtime}/Core/IWebSocket.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/MessageEventArgs.cs | 0
.../Runtime}/Core/MessageEventArgs.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/Opcode.cs | 0
{Runtime => Scripts/Runtime}/Core/Opcode.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/OpenEventArgs.cs | 0
{Runtime => Scripts/Runtime}/Core/OpenEventArgs.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/Settings.cs | 0
{Runtime => Scripts/Runtime}/Core/Settings.cs.meta | 0
{Runtime => Scripts/Runtime}/Core/WebSocketState.cs | 0
{Runtime => Scripts/Runtime}/Core/WebSocketState.cs.meta | 0
{Runtime => Scripts/Runtime}/Implementation.meta | 0
{Runtime => Scripts/Runtime}/Implementation/NoWebGL.meta | 0
.../Runtime}/Implementation/NoWebGL/WebSocket.cs | 0
.../Runtime}/Implementation/NoWebGL/WebSocket.cs.meta | 0
.../Runtime}/Implementation/Synchronized.meta | 0
.../Runtime}/Implementation/Synchronized/WebSocket.cs | 0
.../Implementation/Synchronized/WebSocket.cs.meta | 0
.../Implementation/Synchronized/WebSocketManager.cs | 0
.../Implementation/Synchronized/WebSocketManager.cs.meta | 0
{Runtime => Scripts/Runtime}/Implementation/Uniform.meta | 0
.../Runtime}/Implementation/Uniform/WebSocket.cs | 0
.../Runtime}/Implementation/Uniform/WebSocket.cs.meta | 0
{Runtime => Scripts/Runtime}/Implementation/WebGL.meta | 0
.../Runtime}/Implementation/WebGL/WebSocket.cs | 0
.../Runtime}/Implementation/WebGL/WebSocket.cs.meta | 0
.../Runtime}/Implementation/WebGL/WebSocketManager.cs | 0
.../Implementation/WebGL/WebSocketManager.cs.meta | 0
.../Runtime}/UnityWebSocket.Runtime.asmdef | 0
.../Runtime}/UnityWebSocket.Runtime.asmdef.meta | 0
Example.meta => Tests.meta | 0
Example/Example.unity => Tests/Demo.unity | 0
Example/Example.unity.meta => Tests/Demo.unity.meta | 0
.../UnityWebSocket.Test.asmdef | 2 +-
.../UnityWebSocket.Test.asmdef.meta | 0
Example/Example.cs => Tests/UnityWebSocketTest.cs | 2 +-
.../Example.cs.meta => Tests/UnityWebSocketTest.cs.meta | 0
56 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 Scripts.meta
rename Editor.meta => Scripts/Editor.meta (100%)
rename {Editor => Scripts/Editor}/Help.cs (100%)
rename {Editor => Scripts/Editor}/Help.cs.meta (100%)
rename {Editor => Scripts/Editor}/PlayerSettingChecker.cs (100%)
rename {Editor => Scripts/Editor}/PlayerSettingChecker.cs.meta (100%)
rename {Editor => Scripts/Editor}/UnityWebSocket.Editor.asmdef (100%)
rename {Editor => Scripts/Editor}/UnityWebSocket.Editor.asmdef.meta (100%)
rename {Editor => Scripts/Editor}/VersionChecker.cs (100%)
rename {Editor => Scripts/Editor}/VersionChecker.cs.meta (100%)
rename Runtime.meta => Scripts/Runtime.meta (100%)
rename {Runtime => Scripts/Runtime}/Core.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/CloseEventArgs.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/CloseEventArgs.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/CloseStatusCode.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/CloseStatusCode.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/ErrorEventArgs.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/ErrorEventArgs.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/IWebSocket.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/IWebSocket.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/MessageEventArgs.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/MessageEventArgs.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/Opcode.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/Opcode.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/OpenEventArgs.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/OpenEventArgs.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/Settings.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/Settings.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Core/WebSocketState.cs (100%)
rename {Runtime => Scripts/Runtime}/Core/WebSocketState.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/NoWebGL.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/NoWebGL/WebSocket.cs (100%)
rename {Runtime => Scripts/Runtime}/Implementation/NoWebGL/WebSocket.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Synchronized.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Synchronized/WebSocket.cs (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Synchronized/WebSocket.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Synchronized/WebSocketManager.cs (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Synchronized/WebSocketManager.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Uniform.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Uniform/WebSocket.cs (100%)
rename {Runtime => Scripts/Runtime}/Implementation/Uniform/WebSocket.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/WebGL.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/WebGL/WebSocket.cs (100%)
rename {Runtime => Scripts/Runtime}/Implementation/WebGL/WebSocket.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/Implementation/WebGL/WebSocketManager.cs (100%)
rename {Runtime => Scripts/Runtime}/Implementation/WebGL/WebSocketManager.cs.meta (100%)
rename {Runtime => Scripts/Runtime}/UnityWebSocket.Runtime.asmdef (100%)
rename {Runtime => Scripts/Runtime}/UnityWebSocket.Runtime.asmdef.meta (100%)
rename Example.meta => Tests.meta (100%)
rename Example/Example.unity => Tests/Demo.unity (100%)
rename Example/Example.unity.meta => Tests/Demo.unity.meta (100%)
rename Example/UnityWebSocket.Example.asmdef => Tests/UnityWebSocket.Test.asmdef (88%)
rename Example/UnityWebSocket.Example.asmdef.meta => Tests/UnityWebSocket.Test.asmdef.meta (100%)
rename Example/Example.cs => Tests/UnityWebSocketTest.cs (99%)
rename Example/Example.cs.meta => Tests/UnityWebSocketTest.cs.meta (100%)
diff --git a/Scripts.meta b/Scripts.meta
new file mode 100644
index 00000000..0a1e73b4
--- /dev/null
+++ b/Scripts.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 89cd0cf8603ef4069b2f6a5d79cbdbe1
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor.meta b/Scripts/Editor.meta
similarity index 100%
rename from Editor.meta
rename to Scripts/Editor.meta
diff --git a/Editor/Help.cs b/Scripts/Editor/Help.cs
similarity index 100%
rename from Editor/Help.cs
rename to Scripts/Editor/Help.cs
diff --git a/Editor/Help.cs.meta b/Scripts/Editor/Help.cs.meta
similarity index 100%
rename from Editor/Help.cs.meta
rename to Scripts/Editor/Help.cs.meta
diff --git a/Editor/PlayerSettingChecker.cs b/Scripts/Editor/PlayerSettingChecker.cs
similarity index 100%
rename from Editor/PlayerSettingChecker.cs
rename to Scripts/Editor/PlayerSettingChecker.cs
diff --git a/Editor/PlayerSettingChecker.cs.meta b/Scripts/Editor/PlayerSettingChecker.cs.meta
similarity index 100%
rename from Editor/PlayerSettingChecker.cs.meta
rename to Scripts/Editor/PlayerSettingChecker.cs.meta
diff --git a/Editor/UnityWebSocket.Editor.asmdef b/Scripts/Editor/UnityWebSocket.Editor.asmdef
similarity index 100%
rename from Editor/UnityWebSocket.Editor.asmdef
rename to Scripts/Editor/UnityWebSocket.Editor.asmdef
diff --git a/Editor/UnityWebSocket.Editor.asmdef.meta b/Scripts/Editor/UnityWebSocket.Editor.asmdef.meta
similarity index 100%
rename from Editor/UnityWebSocket.Editor.asmdef.meta
rename to Scripts/Editor/UnityWebSocket.Editor.asmdef.meta
diff --git a/Editor/VersionChecker.cs b/Scripts/Editor/VersionChecker.cs
similarity index 100%
rename from Editor/VersionChecker.cs
rename to Scripts/Editor/VersionChecker.cs
diff --git a/Editor/VersionChecker.cs.meta b/Scripts/Editor/VersionChecker.cs.meta
similarity index 100%
rename from Editor/VersionChecker.cs.meta
rename to Scripts/Editor/VersionChecker.cs.meta
diff --git a/Runtime.meta b/Scripts/Runtime.meta
similarity index 100%
rename from Runtime.meta
rename to Scripts/Runtime.meta
diff --git a/Runtime/Core.meta b/Scripts/Runtime/Core.meta
similarity index 100%
rename from Runtime/Core.meta
rename to Scripts/Runtime/Core.meta
diff --git a/Runtime/Core/CloseEventArgs.cs b/Scripts/Runtime/Core/CloseEventArgs.cs
similarity index 100%
rename from Runtime/Core/CloseEventArgs.cs
rename to Scripts/Runtime/Core/CloseEventArgs.cs
diff --git a/Runtime/Core/CloseEventArgs.cs.meta b/Scripts/Runtime/Core/CloseEventArgs.cs.meta
similarity index 100%
rename from Runtime/Core/CloseEventArgs.cs.meta
rename to Scripts/Runtime/Core/CloseEventArgs.cs.meta
diff --git a/Runtime/Core/CloseStatusCode.cs b/Scripts/Runtime/Core/CloseStatusCode.cs
similarity index 100%
rename from Runtime/Core/CloseStatusCode.cs
rename to Scripts/Runtime/Core/CloseStatusCode.cs
diff --git a/Runtime/Core/CloseStatusCode.cs.meta b/Scripts/Runtime/Core/CloseStatusCode.cs.meta
similarity index 100%
rename from Runtime/Core/CloseStatusCode.cs.meta
rename to Scripts/Runtime/Core/CloseStatusCode.cs.meta
diff --git a/Runtime/Core/ErrorEventArgs.cs b/Scripts/Runtime/Core/ErrorEventArgs.cs
similarity index 100%
rename from Runtime/Core/ErrorEventArgs.cs
rename to Scripts/Runtime/Core/ErrorEventArgs.cs
diff --git a/Runtime/Core/ErrorEventArgs.cs.meta b/Scripts/Runtime/Core/ErrorEventArgs.cs.meta
similarity index 100%
rename from Runtime/Core/ErrorEventArgs.cs.meta
rename to Scripts/Runtime/Core/ErrorEventArgs.cs.meta
diff --git a/Runtime/Core/IWebSocket.cs b/Scripts/Runtime/Core/IWebSocket.cs
similarity index 100%
rename from Runtime/Core/IWebSocket.cs
rename to Scripts/Runtime/Core/IWebSocket.cs
diff --git a/Runtime/Core/IWebSocket.cs.meta b/Scripts/Runtime/Core/IWebSocket.cs.meta
similarity index 100%
rename from Runtime/Core/IWebSocket.cs.meta
rename to Scripts/Runtime/Core/IWebSocket.cs.meta
diff --git a/Runtime/Core/MessageEventArgs.cs b/Scripts/Runtime/Core/MessageEventArgs.cs
similarity index 100%
rename from Runtime/Core/MessageEventArgs.cs
rename to Scripts/Runtime/Core/MessageEventArgs.cs
diff --git a/Runtime/Core/MessageEventArgs.cs.meta b/Scripts/Runtime/Core/MessageEventArgs.cs.meta
similarity index 100%
rename from Runtime/Core/MessageEventArgs.cs.meta
rename to Scripts/Runtime/Core/MessageEventArgs.cs.meta
diff --git a/Runtime/Core/Opcode.cs b/Scripts/Runtime/Core/Opcode.cs
similarity index 100%
rename from Runtime/Core/Opcode.cs
rename to Scripts/Runtime/Core/Opcode.cs
diff --git a/Runtime/Core/Opcode.cs.meta b/Scripts/Runtime/Core/Opcode.cs.meta
similarity index 100%
rename from Runtime/Core/Opcode.cs.meta
rename to Scripts/Runtime/Core/Opcode.cs.meta
diff --git a/Runtime/Core/OpenEventArgs.cs b/Scripts/Runtime/Core/OpenEventArgs.cs
similarity index 100%
rename from Runtime/Core/OpenEventArgs.cs
rename to Scripts/Runtime/Core/OpenEventArgs.cs
diff --git a/Runtime/Core/OpenEventArgs.cs.meta b/Scripts/Runtime/Core/OpenEventArgs.cs.meta
similarity index 100%
rename from Runtime/Core/OpenEventArgs.cs.meta
rename to Scripts/Runtime/Core/OpenEventArgs.cs.meta
diff --git a/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
similarity index 100%
rename from Runtime/Core/Settings.cs
rename to Scripts/Runtime/Core/Settings.cs
diff --git a/Runtime/Core/Settings.cs.meta b/Scripts/Runtime/Core/Settings.cs.meta
similarity index 100%
rename from Runtime/Core/Settings.cs.meta
rename to Scripts/Runtime/Core/Settings.cs.meta
diff --git a/Runtime/Core/WebSocketState.cs b/Scripts/Runtime/Core/WebSocketState.cs
similarity index 100%
rename from Runtime/Core/WebSocketState.cs
rename to Scripts/Runtime/Core/WebSocketState.cs
diff --git a/Runtime/Core/WebSocketState.cs.meta b/Scripts/Runtime/Core/WebSocketState.cs.meta
similarity index 100%
rename from Runtime/Core/WebSocketState.cs.meta
rename to Scripts/Runtime/Core/WebSocketState.cs.meta
diff --git a/Runtime/Implementation.meta b/Scripts/Runtime/Implementation.meta
similarity index 100%
rename from Runtime/Implementation.meta
rename to Scripts/Runtime/Implementation.meta
diff --git a/Runtime/Implementation/NoWebGL.meta b/Scripts/Runtime/Implementation/NoWebGL.meta
similarity index 100%
rename from Runtime/Implementation/NoWebGL.meta
rename to Scripts/Runtime/Implementation/NoWebGL.meta
diff --git a/Runtime/Implementation/NoWebGL/WebSocket.cs b/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs
similarity index 100%
rename from Runtime/Implementation/NoWebGL/WebSocket.cs
rename to Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs
diff --git a/Runtime/Implementation/NoWebGL/WebSocket.cs.meta b/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs.meta
similarity index 100%
rename from Runtime/Implementation/NoWebGL/WebSocket.cs.meta
rename to Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs.meta
diff --git a/Runtime/Implementation/Synchronized.meta b/Scripts/Runtime/Implementation/Synchronized.meta
similarity index 100%
rename from Runtime/Implementation/Synchronized.meta
rename to Scripts/Runtime/Implementation/Synchronized.meta
diff --git a/Runtime/Implementation/Synchronized/WebSocket.cs b/Scripts/Runtime/Implementation/Synchronized/WebSocket.cs
similarity index 100%
rename from Runtime/Implementation/Synchronized/WebSocket.cs
rename to Scripts/Runtime/Implementation/Synchronized/WebSocket.cs
diff --git a/Runtime/Implementation/Synchronized/WebSocket.cs.meta b/Scripts/Runtime/Implementation/Synchronized/WebSocket.cs.meta
similarity index 100%
rename from Runtime/Implementation/Synchronized/WebSocket.cs.meta
rename to Scripts/Runtime/Implementation/Synchronized/WebSocket.cs.meta
diff --git a/Runtime/Implementation/Synchronized/WebSocketManager.cs b/Scripts/Runtime/Implementation/Synchronized/WebSocketManager.cs
similarity index 100%
rename from Runtime/Implementation/Synchronized/WebSocketManager.cs
rename to Scripts/Runtime/Implementation/Synchronized/WebSocketManager.cs
diff --git a/Runtime/Implementation/Synchronized/WebSocketManager.cs.meta b/Scripts/Runtime/Implementation/Synchronized/WebSocketManager.cs.meta
similarity index 100%
rename from Runtime/Implementation/Synchronized/WebSocketManager.cs.meta
rename to Scripts/Runtime/Implementation/Synchronized/WebSocketManager.cs.meta
diff --git a/Runtime/Implementation/Uniform.meta b/Scripts/Runtime/Implementation/Uniform.meta
similarity index 100%
rename from Runtime/Implementation/Uniform.meta
rename to Scripts/Runtime/Implementation/Uniform.meta
diff --git a/Runtime/Implementation/Uniform/WebSocket.cs b/Scripts/Runtime/Implementation/Uniform/WebSocket.cs
similarity index 100%
rename from Runtime/Implementation/Uniform/WebSocket.cs
rename to Scripts/Runtime/Implementation/Uniform/WebSocket.cs
diff --git a/Runtime/Implementation/Uniform/WebSocket.cs.meta b/Scripts/Runtime/Implementation/Uniform/WebSocket.cs.meta
similarity index 100%
rename from Runtime/Implementation/Uniform/WebSocket.cs.meta
rename to Scripts/Runtime/Implementation/Uniform/WebSocket.cs.meta
diff --git a/Runtime/Implementation/WebGL.meta b/Scripts/Runtime/Implementation/WebGL.meta
similarity index 100%
rename from Runtime/Implementation/WebGL.meta
rename to Scripts/Runtime/Implementation/WebGL.meta
diff --git a/Runtime/Implementation/WebGL/WebSocket.cs b/Scripts/Runtime/Implementation/WebGL/WebSocket.cs
similarity index 100%
rename from Runtime/Implementation/WebGL/WebSocket.cs
rename to Scripts/Runtime/Implementation/WebGL/WebSocket.cs
diff --git a/Runtime/Implementation/WebGL/WebSocket.cs.meta b/Scripts/Runtime/Implementation/WebGL/WebSocket.cs.meta
similarity index 100%
rename from Runtime/Implementation/WebGL/WebSocket.cs.meta
rename to Scripts/Runtime/Implementation/WebGL/WebSocket.cs.meta
diff --git a/Runtime/Implementation/WebGL/WebSocketManager.cs b/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs
similarity index 100%
rename from Runtime/Implementation/WebGL/WebSocketManager.cs
rename to Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs
diff --git a/Runtime/Implementation/WebGL/WebSocketManager.cs.meta b/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs.meta
similarity index 100%
rename from Runtime/Implementation/WebGL/WebSocketManager.cs.meta
rename to Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs.meta
diff --git a/Runtime/UnityWebSocket.Runtime.asmdef b/Scripts/Runtime/UnityWebSocket.Runtime.asmdef
similarity index 100%
rename from Runtime/UnityWebSocket.Runtime.asmdef
rename to Scripts/Runtime/UnityWebSocket.Runtime.asmdef
diff --git a/Runtime/UnityWebSocket.Runtime.asmdef.meta b/Scripts/Runtime/UnityWebSocket.Runtime.asmdef.meta
similarity index 100%
rename from Runtime/UnityWebSocket.Runtime.asmdef.meta
rename to Scripts/Runtime/UnityWebSocket.Runtime.asmdef.meta
diff --git a/Example.meta b/Tests.meta
similarity index 100%
rename from Example.meta
rename to Tests.meta
diff --git a/Example/Example.unity b/Tests/Demo.unity
similarity index 100%
rename from Example/Example.unity
rename to Tests/Demo.unity
diff --git a/Example/Example.unity.meta b/Tests/Demo.unity.meta
similarity index 100%
rename from Example/Example.unity.meta
rename to Tests/Demo.unity.meta
diff --git a/Example/UnityWebSocket.Example.asmdef b/Tests/UnityWebSocket.Test.asmdef
similarity index 88%
rename from Example/UnityWebSocket.Example.asmdef
rename to Tests/UnityWebSocket.Test.asmdef
index b7d0b3e0..28aadfb0 100644
--- a/Example/UnityWebSocket.Example.asmdef
+++ b/Tests/UnityWebSocket.Test.asmdef
@@ -1,5 +1,5 @@
{
- "name": "UnityWebSocket.Example",
+ "name": "UnityWebSocket.Test",
"references": [
"UnityWebSocket.Runtime"
],
diff --git a/Example/UnityWebSocket.Example.asmdef.meta b/Tests/UnityWebSocket.Test.asmdef.meta
similarity index 100%
rename from Example/UnityWebSocket.Example.asmdef.meta
rename to Tests/UnityWebSocket.Test.asmdef.meta
diff --git a/Example/Example.cs b/Tests/UnityWebSocketTest.cs
similarity index 99%
rename from Example/Example.cs
rename to Tests/UnityWebSocketTest.cs
index 3319cda7..783915a5 100644
--- a/Example/Example.cs
+++ b/Tests/UnityWebSocketTest.cs
@@ -2,7 +2,7 @@
using UnityEngine;
using UnityWebSocket;
-public class Example : MonoBehaviour
+public class UnityWebSocketTest : MonoBehaviour
{
public string url = "ws://echo.websocket.org";
private IWebSocket socket;
diff --git a/Example/Example.cs.meta b/Tests/UnityWebSocketTest.cs.meta
similarity index 100%
rename from Example/Example.cs.meta
rename to Tests/UnityWebSocketTest.cs.meta
From 5b32a013d886a130c9e8f5e61858786f7c2ac04b Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 11:10:56 +0800
Subject: [PATCH 03/66] useless code
---
Tests/UnityWebSocketTest.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Tests/UnityWebSocketTest.cs b/Tests/UnityWebSocketTest.cs
index 783915a5..17d0c5c2 100644
--- a/Tests/UnityWebSocketTest.cs
+++ b/Tests/UnityWebSocketTest.cs
@@ -1,5 +1,4 @@
-using System;
-using UnityEngine;
+using UnityEngine;
using UnityWebSocket;
public class UnityWebSocketTest : MonoBehaviour
From 7d9afd7fa4cbf34eb384a6d24a374eefaf9a0353 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 15:43:54 +0800
Subject: [PATCH 04/66] remove asmdef
---
.asmdef | 0
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 .asmdef
diff --git a/.asmdef b/.asmdef
deleted file mode 100644
index e69de29b..00000000
From 73256d0717092c92d17326f8d6d3b6b04317ae89 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 16:33:10 +0800
Subject: [PATCH 05/66] package.json
---
package.json | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 package.json
diff --git a/package.json b/package.json
new file mode 100644
index 00000000..3465a5f7
--- /dev/null
+++ b/package.json
@@ -0,0 +1,17 @@
+{
+ "name": "com.psygame.unitywebsocket",
+ "displayName": "UnityWebSocket",
+ "version": "2.2.0",
+ "unity": "2018.3",
+ "description": "The Best Unity WebSocket Plugin for All Platforms.",
+ "keywords": [ "websocket", "webgl", "socket", "jslib" ],
+ "category": "network",
+ "dependencies": {},
+ "samples": [
+ {
+ "displayName": "Demo Scene",
+ "description": "Demo Scene",
+ "path": "Samples~/DemoScene"
+ }
+ ]
+}
From 6ec2c23a8591761419813f637879b3d5bc5278fc Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 16:54:52 +0800
Subject: [PATCH 06/66] remove samples
---
package.json | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/package.json b/package.json
index 3465a5f7..7d160ca1 100644
--- a/package.json
+++ b/package.json
@@ -6,12 +6,6 @@
"description": "The Best Unity WebSocket Plugin for All Platforms.",
"keywords": [ "websocket", "webgl", "socket", "jslib" ],
"category": "network",
- "dependencies": {},
- "samples": [
- {
- "displayName": "Demo Scene",
- "description": "Demo Scene",
- "path": "Samples~/DemoScene"
- }
+ "dependencies": {}
]
}
From 4fd249df3bef80fe671a608175eaff130842998e Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 17:11:16 +0800
Subject: [PATCH 07/66] fix pack
---
package.json | 1 -
1 file changed, 1 deletion(-)
diff --git a/package.json b/package.json
index 7d160ca1..d375c059 100644
--- a/package.json
+++ b/package.json
@@ -7,5 +7,4 @@
"keywords": [ "websocket", "webgl", "socket", "jslib" ],
"category": "network",
"dependencies": {}
- ]
}
From b8b281260163a4dcd2fce002f116589e73fc40b1 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 18:00:12 +0800
Subject: [PATCH 08/66] package
---
Samples.meta | 8 ++++++++
{Tests => Samples}/Demo.unity | 0
{Tests => Samples}/Demo.unity.meta | 0
package.json | 21 +++++++++++++++++++--
package.json.meta | 7 +++++++
5 files changed, 34 insertions(+), 2 deletions(-)
create mode 100644 Samples.meta
rename {Tests => Samples}/Demo.unity (100%)
rename {Tests => Samples}/Demo.unity.meta (100%)
create mode 100644 package.json.meta
diff --git a/Samples.meta b/Samples.meta
new file mode 100644
index 00000000..ce4ba709
--- /dev/null
+++ b/Samples.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: cb7ca38423334462f8e2a76cf28d6790
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Tests/Demo.unity b/Samples/Demo.unity
similarity index 100%
rename from Tests/Demo.unity
rename to Samples/Demo.unity
diff --git a/Tests/Demo.unity.meta b/Samples/Demo.unity.meta
similarity index 100%
rename from Tests/Demo.unity.meta
rename to Samples/Demo.unity.meta
diff --git a/package.json b/package.json
index d375c059..519d2c30 100644
--- a/package.json
+++ b/package.json
@@ -2,9 +2,26 @@
"name": "com.psygame.unitywebsocket",
"displayName": "UnityWebSocket",
"version": "2.2.0",
- "unity": "2018.3",
+ "unity": "2018.1",
"description": "The Best Unity WebSocket Plugin for All Platforms.",
"keywords": [ "websocket", "webgl", "socket", "jslib" ],
"category": "network",
- "dependencies": {}
+ "dependencies": {},
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/psygame/UnityWebSocket.git"
+ },
+ "author": {
+ "name": "psygame",
+ "email": "799329256@qq.com",
+ "url": "https://github.com/psygame"
+ },
+ "samples": [
+ {
+ "displayName": "Demo",
+ "description": "Demo Scene",
+ "path": "Samples~/Demo"
+ }
+ ]
}
diff --git a/package.json.meta b/package.json.meta
new file mode 100644
index 00000000..c9fd7611
--- /dev/null
+++ b/package.json.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: cfd1c6a62647e4cd3a883ce1f6e4f032
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
From 4e3c79453679565d26d5a93841bed07b57c36469 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 18:20:31 +0800
Subject: [PATCH 09/66] fix samples, via menu
---
Samples.meta | 8 --------
{Samples => Samples~}/Demo.unity | 0
{Samples => Samples~}/Demo.unity.meta | 0
Scripts/Editor/PlayerSettingChecker.cs | 2 +-
4 files changed, 1 insertion(+), 9 deletions(-)
delete mode 100644 Samples.meta
rename {Samples => Samples~}/Demo.unity (100%)
rename {Samples => Samples~}/Demo.unity.meta (100%)
diff --git a/Samples.meta b/Samples.meta
deleted file mode 100644
index ce4ba709..00000000
--- a/Samples.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: cb7ca38423334462f8e2a76cf28d6790
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Samples/Demo.unity b/Samples~/Demo.unity
similarity index 100%
rename from Samples/Demo.unity
rename to Samples~/Demo.unity
diff --git a/Samples/Demo.unity.meta b/Samples~/Demo.unity.meta
similarity index 100%
rename from Samples/Demo.unity.meta
rename to Samples~/Demo.unity.meta
diff --git a/Scripts/Editor/PlayerSettingChecker.cs b/Scripts/Editor/PlayerSettingChecker.cs
index d6236b7f..52096a65 100644
--- a/Scripts/Editor/PlayerSettingChecker.cs
+++ b/Scripts/Editor/PlayerSettingChecker.cs
@@ -35,7 +35,7 @@ private static void CheckSettings()
if (PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Wasm)
{
EditorUtility.DisplayDialog("Warning"
- , "On WebGL platform WebGL Linker Target should be asm.js or Both, via Menu:\nUnityWebSocket -> LinkerTarget -> asm.js or Both"
+ , "On WebGL platform WebGL Linker Target should be asm.js or Both, via Menu:\nTools -> UnityWebSocket -> LinkerTarget -> asm.js or Both"
, "OK");
}
else if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy)
From d5d1c0ebf224d04f962845990f45092e421dff60 Mon Sep 17 00:00:00 2001
From: psy <799329256@qq.com>
Date: Thu, 13 Aug 2020 18:52:58 +0800
Subject: [PATCH 10/66] Create LICENSE
---
LICENSE | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 LICENSE
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..1dbdad8a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 psy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
From f218c5deadfcdb28cd559667993d9193e78ac959 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 13 Aug 2020 18:57:26 +0800
Subject: [PATCH 11/66] fix some bugs
---
LICENSE.meta | 7 +++++++
Scripts/Editor/VersionChecker.cs | 1 -
2 files changed, 7 insertions(+), 1 deletion(-)
create mode 100644 LICENSE.meta
diff --git a/LICENSE.meta b/LICENSE.meta
new file mode 100644
index 00000000..fb6ddf01
--- /dev/null
+++ b/LICENSE.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ea0105934d01a4ff79019258132fd3d7
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Scripts/Editor/VersionChecker.cs b/Scripts/Editor/VersionChecker.cs
index cdc46c54..b10fde9b 100644
--- a/Scripts/Editor/VersionChecker.cs
+++ b/Scripts/Editor/VersionChecker.cs
@@ -1,7 +1,6 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;
-using UnityWebSocket;
namespace UnityWebSocket.Editor
{
From 099e12327f2a0e82f26709b09fdf9bee8af2b574 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 14 Aug 2020 16:04:57 +0800
Subject: [PATCH 12/66] readme & settings
---
README.md | 111 +++++++++++++++++++++++++++++++
README.md.meta | 7 ++
README_EN.md | 106 +++++++++++++++++++++++++++++
README_EN.md.meta | 7 ++
Scripts/Runtime/Core/Settings.cs | 2 +-
5 files changed, 232 insertions(+), 1 deletion(-)
create mode 100644 README.md
create mode 100644 README.md.meta
create mode 100644 README_EN.md
create mode 100644 README_EN.md.meta
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..0a019cd7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,111 @@
+
+[(English)](README_EN.md)
+
+## 在线示例
+
+- [http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)
+
+## 安装
+
+#### 需要
+
+- Unity 2018.3 或更高。
+- 无其他SDK依赖。
+
+#### 使用 OpenUPM 安装
+
+- SDK已上传至 [OpenUPM](https://openupm.com).
+您可以使用 [openupm-cli](https://github.com/openupm/openupm-cli) 进行安装。
+```
+openupm add com.psygame.unitywebsocket
+```
+
+
+#### 使用 Git 安装
+
+- 在您的项目根路径的 Packages 文件夹中找到 manifest.json 文件,参考如下方式进行修改:
+```js
+{
+ "dependencies": {
+ "com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git",
+ ...
+ },
+}
+```
+
+- 可通过修改链接后缀 `#{version}` 来安装对应版本.
+ * 示例: `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.2.0",`
+
+
+- 或使用 [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) 来安装SDK。
+
+#### 使用 Unity Package 安装
+
+1. 在 [Releases](https://github.com/psygame/UnityWebSocket/releases) 页面下载对应版本的 UnityWebSocket.unitypackage 安装包。
+2. 在您的项目中导入即可。
+
+
+## 使用方法
+
+- 需要如下设置:
+
+ * 需要 Scripting Runtime Version = .Net 4.x
+ * 需要 WebGL LinkerTarger = asm.js or Both
+
+- 使用 WebSocket
+
+ ```csharp
+ // 命名空间
+ using UnityWebSocket;
+
+ // 创建实例
+ WebSocket scoket = new WebSocket();
+
+ // 注册回调
+ scoket.OnOpen += OnOpen;
+ scoket.OnClose += OnClose;
+ scoket.OnMessage += OnMessage;
+ socket.OnError += OnError;
+
+ // 连接
+ string address = "ws://echo.websocket.org";
+ socket.ConnectAsync(address);
+
+ // 发送数据(两种发送方式)
+ socket.SendAsync(str); // 发送类型 String 类型数据
+ socket.SendAsync(bytes); // 发送 byte[] 类型数据
+
+ // 关闭连接
+ socket.CloseAsync();
+ ```
+
+- 详细使用方法可参考项目中的 [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) 示例代码。
+
+#### 3. 注意(Warning)
+
+- 插件中多个命名空间中存在 **WebSocket** 类,适用不同环境。
+
+ 命名空间 | 平台 | 方式 | 说明
+ -|-|-|-
+ UnityWebSocket | 全平台 | 同步(无阻塞) | **[推荐]** 无需考虑异步回调使用 Unity 组件的问题。
+ UnityWebSocket.Uniform | 全平台 | 异步 | 需要考虑异步回调使用 Unity 组件的问题。
+ UnityWebSocket.WebGL | WebGL平台 | 异步 | 仅支持WebGL平台下的通信。
+ UnityWebSocket.NoWebGL | 非WebGL平台 | 异步 | 仅支持非WebGL平台下的通信。
+
+#### 4. WebGL 模块说明
+
+- WebSocket.jslib 语法格式需要遵循 [asm.js](http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html)。
+
+ 路径:Plugins/WebGL/WebSocket.jslib
+ 作用:Unity发布WebGL版本会将其加入到js运行库中。
+
+- Example 场景
+
+ 作用:WebSocket的使用方法示例。
+
+#### 5. WebSocket 服务器
+
+- 使用官方提供的 Echo Test 服务器。参考 [Echo Test](http://www.websocket.org/echo.html)。
+
+#### 6. QQ 交流群
+- 1126457634 >>> [入群通道](https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd) <<<
diff --git a/README.md.meta b/README.md.meta
new file mode 100644
index 00000000..80240058
--- /dev/null
+++ b/README.md.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ce84b896fd4134c199be2a6c5b574994
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/README_EN.md b/README_EN.md
new file mode 100644
index 00000000..249a91cd
--- /dev/null
+++ b/README_EN.md
@@ -0,0 +1,106 @@
+
+[(中文版)](README.md)
+
+## Online Demo
+
+- [http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)
+
+## Installation
+
+#### Requirement
+
+- Unity 2018.3 or later
+- No other SDK are required
+
+#### Using OpenUPM
+
+- This package is available on [OpenUPM](https://openupm.com).
+You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
+```
+openupm add com.psygame.unitywebsocket
+```
+
+#### Using Git
+
+- Find the manifest.json file in the Packages folder of your project and edit it to look like this:
+```js
+{
+ "dependencies": {
+ "com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git",
+ ...
+ },
+}
+```
+
+- To update the package, change suffix `#{version}` to the target version.
+ * e.g. `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.2.0",`
+
+- Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) to install and update the package.
+
+#### Using Unity Package
+
+1. Download a UnityWebSocket.unitypackage file from [Releases](https://github.com/psygame/UnityWebSocket/releases) page.
+2. Import it into your Unity project.
+
+
+## Usage:
+
+- Require Settings:
+
+ * Require Scripting Runtime Version = .Net 4.x
+ * Require WebGL LinkerTarger = asm.js or Both
+
+- Easy to use WebSocket
+
+ ```csharp
+ // the namespace
+ using UnityWebSocket;
+
+ // create instance
+ WebSocket scoket = new WebSocket();
+
+ // register callback
+ scoket.OnOpen += OnOpen;
+ scoket.OnClose += OnClose;
+ scoket.OnMessage += OnMessage;
+ socket.OnError += OnError;
+
+ // connect
+ string address = "ws://echo.websocket.org";
+ socket.ConnectAsync(address);
+
+ // send data (tow ways)
+ socket.SendAsync(str); // send String data
+ socket.SendAsync(bytes); // send byte[] data
+
+ // close connection
+ socket.CloseAsync();
+ ```
+
+- more detail usage, see the [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) code in project。
+
+#### 3. Attention(Warning)
+
+- there are many **WebSocket** class in different namespace, use in different situations.
+
+ namespace | platform | sync style | description
+ -|-|-|-
+ UnityWebSocket | all | synchronized(no block) | **[recommend]** no need consider the problem by using unity component in asynchronized callback.
+ UnityWebSocket.Uniform | all | asynchronized | consider the problem by using unity component in asynchronized callback.
+ UnityWebSocket.WebGL | WebGL only | asynchronized | only run in WebGL platform.
+ UnityWebSocket.NoWebGL | WebGL except | asynchronized | only run in not WebGL platforms.
+
+#### 4. WebGL Module Introduction
+
+- WebSocket.jslib, syntax follow to [asm.js](http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html)。
+
+ Path: Plugins/WebGL/WebSocket.jslib
+ Fucntion:Unity will deploy it to web js runtime on WebGL platform.
+
+- Example Scene
+
+ Function: Example how to use UnityWebSocket.
+
+#### 5. WebSocket Server
+
+- use Official Echo Test Server. refer to [Echo Test](http://www.websocket.org/echo.html).
diff --git a/README_EN.md.meta b/README_EN.md.meta
new file mode 100644
index 00000000..c4c825cb
--- /dev/null
+++ b/README_EN.md.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 44d2190dfcf3b45cab7c241421b8ab9f
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index cd4eef35..981984b7 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -6,6 +6,6 @@ public static class Settings
public const string QQ = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
public const string EMAIL = "799329256@qq.com";
public const string AUHTOR = "psygame";
- public const string VERSION = "2.1.0";
+ public const string VERSION = "2.2.0";
}
}
From 1ff701ac042fc724d48c90639b52e3e383252f26 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 14 Aug 2020 16:10:47 +0800
Subject: [PATCH 13/66] fix readme
---
README.md | 26 +++++++++++++-------------
README_EN.md | 26 +++++++++++++-------------
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index 0a019cd7..ac5bcd8f 100644
--- a/README.md
+++ b/README.md
@@ -16,22 +16,22 @@
- SDK已上传至 [OpenUPM](https://openupm.com).
您可以使用 [openupm-cli](https://github.com/openupm/openupm-cli) 进行安装。
-```
-openupm add com.psygame.unitywebsocket
-```
+ ```
+ openupm add com.psygame.unitywebsocket
+ ```
#### 使用 Git 安装
- 在您的项目根路径的 Packages 文件夹中找到 manifest.json 文件,参考如下方式进行修改:
-```js
-{
- "dependencies": {
- "com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git",
- ...
- },
-}
-```
+ ```js
+ {
+ "dependencies": {
+ "com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git",
+ ...
+ },
+ }
+ ```
- 可通过修改链接后缀 `#{version}` 来安装对应版本.
* 示例: `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.2.0",`
@@ -41,8 +41,8 @@ openupm add com.psygame.unitywebsocket
#### 使用 Unity Package 安装
-1. 在 [Releases](https://github.com/psygame/UnityWebSocket/releases) 页面下载对应版本的 UnityWebSocket.unitypackage 安装包。
-2. 在您的项目中导入即可。
+- 在 [Releases](https://github.com/psygame/UnityWebSocket/releases) 页面中,下载对应版本的 UnityWebSocket.unitypackage 安装包。
+- 在您的项目中导入安装包。
## 使用方法
diff --git a/README_EN.md b/README_EN.md
index 249a91cd..55105056 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -16,21 +16,21 @@
- This package is available on [OpenUPM](https://openupm.com).
You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
-```
-openupm add com.psygame.unitywebsocket
-```
+ ```
+ openupm add com.psygame.unitywebsocket
+ ```
#### Using Git
- Find the manifest.json file in the Packages folder of your project and edit it to look like this:
-```js
-{
- "dependencies": {
- "com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git",
- ...
- },
-}
-```
+ ```js
+ {
+ "dependencies": {
+ "com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git",
+ ...
+ },
+ }
+ ```
- To update the package, change suffix `#{version}` to the target version.
* e.g. `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.2.0",`
@@ -39,8 +39,8 @@ openupm add com.psygame.unitywebsocket
#### Using Unity Package
-1. Download a UnityWebSocket.unitypackage file from [Releases](https://github.com/psygame/UnityWebSocket/releases) page.
-2. Import it into your Unity project.
+- Download a UnityWebSocket.unitypackage file from [Releases](https://github.com/psygame/UnityWebSocket/releases) page.
+- Import it into your Unity project.
## Usage:
From cf69f6be53f25d99191cc5f82c24c9d88ebc14b2 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 14 Aug 2020 16:13:48 +0800
Subject: [PATCH 14/66] change log
---
CHANGE_LOG.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 CHANGE_LOG.md
diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md
new file mode 100644
index 00000000..e6d70179
--- /dev/null
+++ b/CHANGE_LOG.md
@@ -0,0 +1,56 @@
+## 版本记录
+
+#### v2.2
+- 拆分 Git 库,添加对 PackageManager 支持,添加对 OpenUpm 的支持。
+
+#### v2.1
+- 修改WebGL平台Unity - JS通信方式,使用回调方式替换SendMessage方式。
+- WebGL平台内存管理,内存优化,主动 malloc 和 free 内存。
+- 非WebGL平台内存管理,内存优化,使用对象池方式重复利用对象。
+- 添加 辅助工具,包括:Help,About,Check Updates 等。
+- 添加 Assembly Define 支持,规范项目依赖,非必要接口使用 internal 关键字不予暴露。
+- 目录结构重新整理,使用根路径下唯一UnityWebSocket文件夹作为插件唯一存放位置。
+
+#### v2.0
+- 移除 websocket-sharp 插件,使用 .Net 4.x 内置的 ClientWebSocket 作为非 WebGL 平台下 WebSocket 插件。
+- 添加**同步方式**的WebSocket ,使用者不必再考虑**异步回调**中使用 Unity 组件的问题。
+
+#### v1.3.2
+- 修复 非ssl连接,使用sslConfiguration bug。
+
+#### v1.3.1
+- 修复 Tls error,添加默认协议 Tls,Tls11,Tls12。
+
+#### v1.3
+- 移除服务器Demo,改用 [websocket-sharp](http://www.websocket.org/echo.html) 官方提供的测试服务器。
+- 添加 PlayerSetting -> Linker Target 属性检测。
+
+#### v1.2.2 - pre
+- support for wss(ssl) 支持SSL协议格式(更新了websocket-sharp源码)。
+- 服务器Demo尚未支持 SSL。会在未来版本支持。
+
+#### v1.2.1
+- fix 非WebGL平台打包兼容BUG(屏蔽websocket-jslib部分代码)。
+
+#### v1.2
+- 重构代码,规范代码,模块整理。
+- 规范接口,参考websocket-sharp结构,使用EventHandler方式处理事件。
+- 添加了字符串数据收发的支持。
+- jslib中添加了获取socket.readyState的方法。
+- jslib中的SendMessage参数整理。
+- fix some Bugs.
+
+#### v1.1
+- 多平台支持,使用websocket-sharp 开源插件。
+- 完善项目命名空间,目录结构。
+- WebSocket增加异步连接发送方法。(webgl平台下仍调用同步方式)
+- 添加开发分支,git管理方式调整。
+
+#### v1.0
+- 支持单客户端同时创建多个不同WebSocket链接。
+- 添加OnError错误回调。错误码对应错误原因,参考jslib文件。
+- 删除Alert功能(与WebSocket无关,按需求自行添加即可)。
+- Close Event Code 作为链接断开错误信息处理。
+- jslib 内容完善,增加Map管理websocket实例。
+- 修改 State 枚举对应到WebSocket ReadyState。
+- 添加 Release Demo Build 文件。
From 478203382c0aa6316084476e066b64ba783a41ba Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 14 Aug 2020 16:19:24 +0800
Subject: [PATCH 15/66] change log .meta
---
CHANGE_LOG.md.meta | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 CHANGE_LOG.md.meta
diff --git a/CHANGE_LOG.md.meta b/CHANGE_LOG.md.meta
new file mode 100644
index 00000000..eb50635d
--- /dev/null
+++ b/CHANGE_LOG.md.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 8096cdf1023be432aa3d6da41aa4acb7
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
From 4bc208a7ea0a336897197f42608cd79d590935a4 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 18:20:54 +0800
Subject: [PATCH 16/66] fix unity version compatible, add editor panel
---
Scripts/Editor/Help.cs | 45 ---
Scripts/Editor/Help.cs.meta | 11 -
Scripts/Editor/PlayerSettingChecker.cs | 74 ----
Scripts/Editor/PlayerSettingChecker.cs.meta | 11 -
Scripts/Editor/SettingsWindow.cs | 319 ++++++++++++++++++
...Checker.cs.meta => SettingsWindow.cs.meta} | 2 +-
Scripts/Editor/VersionChecker.cs | 97 ------
Scripts/Editor/logo.png | Bin 0 -> 8364 bytes
Scripts/Editor/logo.png.meta | 110 ++++++
Scripts/Runtime/Core/Settings.cs | 7 +-
10 files changed, 435 insertions(+), 241 deletions(-)
delete mode 100644 Scripts/Editor/Help.cs
delete mode 100644 Scripts/Editor/Help.cs.meta
delete mode 100644 Scripts/Editor/PlayerSettingChecker.cs
delete mode 100644 Scripts/Editor/PlayerSettingChecker.cs.meta
create mode 100644 Scripts/Editor/SettingsWindow.cs
rename Scripts/Editor/{VersionChecker.cs.meta => SettingsWindow.cs.meta} (83%)
delete mode 100644 Scripts/Editor/VersionChecker.cs
create mode 100644 Scripts/Editor/logo.png
create mode 100644 Scripts/Editor/logo.png.meta
diff --git a/Scripts/Editor/Help.cs b/Scripts/Editor/Help.cs
deleted file mode 100644
index e2e407b6..00000000
--- a/Scripts/Editor/Help.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using UnityEditor;
-using UnityEngine;
-
-namespace UnityWebSocket.Editor
-{
- public class About
- {
- [MenuItem("Tools/UnityWebSocket/Help/Home Page")]
- public static void HelpHomePage()
- {
- Application.OpenURL(Settings.GITHUB);
- }
-
- [MenuItem("Tools/UnityWebSocket/Help/Report an Issue")]
- public static void HelpReportIssue()
- {
- Application.OpenURL(Settings.GITHUB + "/issues/new");
- }
-
- [MenuItem("Tools/UnityWebSocket/Help/Feedback")]
- public static void HelpContact()
- {
- var uri = new System.Uri(string.Format("mailto:{0}?subject={1}", Settings.EMAIL, "UnityWebSocket Feedback"));
- Application.OpenURL(uri.AbsoluteUri);
- }
-
- [MenuItem("Tools/UnityWebSocket/Help/QQ群")]
- public static void HelpContactQQ()
- {
- Application.OpenURL(Settings.QQ);
- }
-
- [MenuItem("Tools/UnityWebSocket/About")]
- public static void AboutDialog()
- {
- var title = "UnityWebSocket";
- var content = "\n"
- + $"Version: {Settings.VERSION}\n\n"
- + $"Author: {Settings.AUHTOR}\n\n"
- + $"E-mail: {Settings.EMAIL}\n\n"
- + $"All rights reserved";
- EditorUtility.DisplayDialog(title, content, "OK");
- }
- }
-}
\ No newline at end of file
diff --git a/Scripts/Editor/Help.cs.meta b/Scripts/Editor/Help.cs.meta
deleted file mode 100644
index 1ee9d407..00000000
--- a/Scripts/Editor/Help.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 6a935232acb8147108f2b80751be5d2f
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Scripts/Editor/PlayerSettingChecker.cs b/Scripts/Editor/PlayerSettingChecker.cs
deleted file mode 100644
index 52096a65..00000000
--- a/Scripts/Editor/PlayerSettingChecker.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using UnityEditor;
-
-namespace UnityWebSocket.Editor
-{
- public class PlayerSettingChecker
- {
-#if UNITY_2018_1_OR_NEWER
- [MenuItem("Tools/UnityWebSocket/LinkerTarget/Wasm", false, 1)]
- private static void WebSocketSettingLinkerTargetWasm()
- {
- PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
- }
-
- [MenuItem("Tools/UnityWebSocket/LinkerTarget/Wasm", true, 1)]
- private static bool WebSocketSettingLinkerTargetWasmValidate()
- {
- return false;
- }
-
- [MenuItem("Tools/UnityWebSocket/LinkerTarget/asm.js", false, 0)]
- private static void WebSocketSettingLinkerTargetAsm()
- {
- PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Asm;
- }
-
- [MenuItem("Tools/UnityWebSocket/LinkerTarget/Both", false, 2)]
- private static void WebSocketSettingLinkerTargetBoth()
- {
- PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;
- }
-
- // [MenuItem("Tools/UnityWebSocket/Check Settings", false, 10)]
- private static void CheckSettings()
- {
- if (PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Wasm)
- {
- EditorUtility.DisplayDialog("Warning"
- , "On WebGL platform WebGL Linker Target should be asm.js or Both, via Menu:\nTools -> UnityWebSocket -> LinkerTarget -> asm.js or Both"
- , "OK");
- }
- else if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy)
- {
- EditorUtility.DisplayDialog("Warning"
- , "Scripting Runtime Version should be .NET 4.x, via Menu:\nPlayerSettings -> Other Settings -> Scripting Runtime Version -> .Net 4.x Equivalent"
- , "OK");
- }
- else
- {
- EditorUtility.DisplayDialog("Success"
- , "Your settings is OK."
- , "OK");
- }
- }
-
- [InitializeOnLoadMethod]
- public static void OnInit()
- {
- if (PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Wasm)
- {
- EditorUtility.DisplayDialog("Warning"
- , "On WebGL platform WebGL Linker Target should be Asm or Both, via Menu:\nUnityWebSocket -> LinkerTarget -> Asm or Both"
- , "OK");
- }
-
- if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy)
- {
- EditorUtility.DisplayDialog("Warning"
- , "Scripting Runtime Version should be .NET 4.x, via Menu:\nPlayerSettings -> Other Settings -> Scripting Runtime Version -> .Net 4.x Equivalent"
- , "OK");
- }
- }
-#endif
- }
-}
\ No newline at end of file
diff --git a/Scripts/Editor/PlayerSettingChecker.cs.meta b/Scripts/Editor/PlayerSettingChecker.cs.meta
deleted file mode 100644
index 75c51564..00000000
--- a/Scripts/Editor/PlayerSettingChecker.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 5031c7d4e788047639083e2fe2aa5787
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
new file mode 100644
index 00000000..993ed3fd
--- /dev/null
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -0,0 +1,319 @@
+using UnityEngine;
+using UnityEditor;
+using UnityEngine.Networking;
+using System.IO;
+
+namespace UnityWebSocket.Editor
+{
+ public class SettingsWindow : EditorWindow
+ {
+ static SettingsWindow window = null;
+ [MenuItem("Tools/UnityWebSocket", priority = 1)]
+ public static void Open()
+ {
+ if (window != null)
+ {
+ window.Close();
+ }
+
+ window = GetWindow(true, "UnityWebSocket");
+ window.minSize = window.maxSize = new Vector2(600, 310);
+ window.Show();
+ window.BeginCheck();
+ }
+
+ private void OnGUI()
+ {
+ DrawLogo();
+ DrawVersion();
+ DrawSeparator(80);
+ DrawFixSettings();
+ DrawSeparator(186);
+ DrawHelper();
+ DrawFooter();
+ }
+
+ private void DrawLogo()
+ {
+ var logo = AssetDatabase.LoadAssetAtPath("Assets/UnityWebSocket/Scripts/Editor/logo.png");
+ var logoPos = new Rect(10, 10, 66, 66);
+ GUI.DrawTexture(logoPos, logo);
+
+ var title = "UnityWebSocket";
+ var titlePos = new Rect(80, 28, 500, 50);
+ GUI.Label(titlePos, title, TextStyle(24));
+ }
+
+ private void DrawSeparator(int y)
+ {
+ EditorGUI.DrawRect(new Rect(10, y, 580, 1), Color.white * 0.5f);
+ }
+
+ private GUIStyle TextStyle(int fontSize = 10, TextAnchor alignment = TextAnchor.UpperLeft)
+ {
+ var style = new GUIStyle();
+ style.fontSize = fontSize;
+ style.normal.textColor = Color.white * 0.85f;
+ style.alignment = alignment;
+ style.richText = true;
+ return style;
+ }
+
+ private void DrawVersion()
+ {
+ GUI.Label(new Rect(440, 10, 150, 10), "Current Version: " + Settings.VERSION, TextStyle(alignment: TextAnchor.MiddleCenter));
+ if (string.IsNullOrEmpty(latestVersion))
+ {
+ GUI.Label(new Rect(440, 30, 150, 10), "Checking Update...", TextStyle(alignment: TextAnchor.MiddleCenter));
+ }
+ else
+ {
+ GUI.Label(new Rect(440, 30, 150, 10), "Latest Version: " + latestVersion, TextStyle(alignment: TextAnchor.MiddleCenter));
+ if (Settings.VERSION == latestVersion)
+ {
+ if (GUI.Button(new Rect(440, 50, 150, 18), "Check Update"))
+ {
+ latestVersion = "";
+ changeLog = "";
+ BeginCheck();
+ }
+ }
+ else
+ {
+ if (GUI.Button(new Rect(440, 50, 150, 18), "Update to | " + latestVersion))
+ {
+ ShowUpdateDialog();
+ }
+ }
+ }
+ }
+
+ private void ShowUpdateDialog()
+ {
+ var code = EditorUtility.DisplayDialog("UnityWebSocket",
+ "Update UnityWebSocket now?\n" + changeLog,
+ "Update Now", "Cancel");
+
+ if (code)
+ {
+ UpdateVersion();
+ }
+ }
+
+ private void UpdateVersion()
+ {
+ // via git
+ var packagePath = Path.Combine(Application.dataPath, "../Packages/manifest.json");
+ if (File.Exists(packagePath))
+ {
+ var txt = File.ReadAllText(packagePath);
+ var index = txt.IndexOf("\"" + Settings.PACKAGE_NAME + "\"");
+ if (index != -1)
+ {
+ var end_index = txt.IndexOf(",", index);
+ var old_str = txt.Substring(index, end_index);
+ var new_str = string.Format("\"{0}\": \"{1}#{2}\"", Settings.PACKAGE_NAME, Settings.UPM_URL, Settings.VERSION);
+ txt = txt.Replace(old_str, new_str);
+ File.WriteAllText(packagePath, txt);
+ AssetDatabase.Refresh();
+ return;
+ }
+ }
+
+ // via releases
+ Application.OpenURL(Settings.GITHUB);
+ }
+
+ private void DrawFixSettings()
+ {
+ bool isRuntimeVersionFixed;
+ bool isLinkTargetFixed;
+ bool isMemorySizeFixed;
+ bool isDecompressionFallbackFixed;
+ PlayerSettingsChecker.GetSettingsFixed(out isRuntimeVersionFixed, out isLinkTargetFixed, out isMemorySizeFixed, out isDecompressionFallbackFixed);
+ bool isAllFixed = isRuntimeVersionFixed && isLinkTargetFixed && isMemorySizeFixed && isDecompressionFallbackFixed;
+ if (isAllFixed)
+ {
+ var str = "All Settings Fixed:";
+ str += "\n√ PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;";
+ str += "\n√ PlayerSettings.WebGL.memorySize = " + PlayerSettings.WebGL.memorySize + ";";
+ str += "\n√ PlayerSettings.WebGL.decompressionFallback = true;";
+#if !UNITY_2019_3_OR_NEWER
+ str += "\n√ PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest;";
+#endif
+ EditorGUI.HelpBox(new Rect(10, 90, 580, 60), str, MessageType.Info);
+ GUI.enabled = false;
+ GUI.Button(new Rect(440, 158, 150, 18), "Auto Fix");
+ GUI.enabled = true;
+ return;
+ }
+
+ var fixStr = "In order to run UnityWebSocket normally, we must fix some SETTINGS below:";
+ if (isLinkTargetFixed)
+ fixStr += "\n√ PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;";
+ else
+ fixStr += "\n× PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;";
+
+ if (isMemorySizeFixed)
+ fixStr += "\n√ PlayerSettings.WebGL.memorySize = " + PlayerSettings.WebGL.memorySize + ";";
+ else
+ fixStr += "\n× PlayerSettings.WebGL.memorySize = [Appropriate Value];";
+
+ if (isDecompressionFallbackFixed)
+ fixStr += "\n√ PlayerSettings.WebGL.decompressionFallback = true;";
+ else
+ fixStr += "\n× PlayerSettings.WebGL.decompressionFallback = true;";
+
+#if !UNITY_2019_3_OR_NEWER
+ if (isRuntimeVersionFixed)
+ fixStr += "\n√ PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest;";
+ else
+ fixStr += "\n× PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest; (Need Manual Fix)";
+#endif
+
+ EditorGUI.HelpBox(new Rect(10, 90, 580, 60), fixStr, MessageType.Warning);
+
+ if (GUI.Button(new Rect(440, 158, 150, 18), "Auto Fix"))
+ {
+#if UNITY_2018_1_OR_NEWER
+ if (!isLinkTargetFixed)
+ PlayerSettings.WebGL.linkerTarget = (WebGLLinkerTarget)2;
+#endif
+
+#if UNITY_2019_1_OR_NEWER
+ if (!isMemorySizeFixed)
+ PlayerSettings.WebGL.memorySize = 128;
+#endif
+
+#if UNITY_2020_1_OR_NEWER
+ if (!isDecompressionFallbackFixed)
+ PlayerSettings.WebGL.decompressionFallback = true;
+#endif
+
+ if (!isRuntimeVersionFixed)
+ EditorUtility.DisplayDialog("UnityWebSocket", "ScriptingRuntimeVersion (.Net 4.x) Need Manual Fix.", "OK");
+ }
+ }
+
+ private void DrawHelper()
+ {
+ GUI.Label(new Rect(330, 200, 100, 18), "GitHub:", TextStyle(10, TextAnchor.MiddleRight));
+ if (GUI.Button(new Rect(440, 200, 150, 18), "UnityWebSocket"))
+ {
+ Application.OpenURL(Settings.GITHUB);
+ }
+
+ GUI.Label(new Rect(330, 225, 100, 18), "Report:", TextStyle(10, TextAnchor.MiddleRight));
+ if (GUI.Button(new Rect(440, 225, 150, 18), "Report an Issue"))
+ {
+ Application.OpenURL(Settings.GITHUB + "/issues/new");
+ }
+
+ GUI.Label(new Rect(330, 250, 100, 18), "Email:", TextStyle(10, TextAnchor.MiddleRight));
+ if (GUI.Button(new Rect(440, 250, 150, 18), Settings.EMAIL))
+ {
+ var uri = new System.Uri(string.Format("mailto:{0}?subject={1}", Settings.EMAIL, "UnityWebSocket Feedback"));
+ Application.OpenURL(uri.AbsoluteUri);
+ }
+
+ GUI.Label(new Rect(330, 275, 100, 18), "QQ群:", TextStyle(10, TextAnchor.MiddleRight));
+ if (GUI.Button(new Rect(440, 275, 150, 18), Settings.QQ_GROUP))
+ {
+ Application.OpenURL(Settings.QQ_GROUP_LINK);
+ }
+ }
+
+ private void DrawFooter()
+ {
+ GUI.Label(new Rect(10, 230, 400, 10), "Developed by " + Settings.AUHTOR, TextStyle(alignment: TextAnchor.MiddleCenter));
+ GUI.Label(new Rect(10, 250, 400, 10), "All rights reserved", TextStyle(alignment: TextAnchor.MiddleCenter));
+ }
+
+ UnityWebRequest req;
+ string changeLog = "";
+ string latestVersion = "";
+ void BeginCheck()
+ {
+ req = UnityWebRequest.Get(Settings.GITHUB + "/releases/latest");
+ EditorApplication.update -= VersionCheckUpdate;
+ EditorApplication.update += VersionCheckUpdate;
+ req.SendWebRequest();
+ }
+ private void VersionCheckUpdate()
+ {
+ if (req == null || req.isNetworkError || req.isHttpError)
+ {
+ EditorApplication.update -= VersionCheckUpdate;
+ return;
+ }
+
+ if (req.isDone)
+ {
+ EditorApplication.update -= VersionCheckUpdate;
+ latestVersion = req.url.Substring(req.url.LastIndexOf("/v") + 2);
+
+ if (Settings.VERSION != latestVersion)
+ {
+ var text = req.downloadHandler.text;
+ var st = text.IndexOf("content=\"v" + latestVersion);
+ st = st > 0 ? text.IndexOf("\n", st) : -1;
+ var end = st > 0 ? text.IndexOf("\" />", st) : -1;
+ if (st > 0 && end > st)
+ {
+ changeLog = text.Substring(st + 1, end - st - 1).Trim();
+ changeLog = changeLog.Replace("\r", "");
+ changeLog = changeLog.Replace("\n", "\n- ");
+ changeLog = "\nCHANGE LOG: \n- " + changeLog + "\n";
+ }
+ }
+
+ Repaint();
+ }
+ }
+ }
+
+
+ public static class PlayerSettingsChecker
+ {
+ [InitializeOnLoadMethod]
+ public static void OnInit()
+ {
+ bool isLinkTargetFixed;
+ bool isMemorySizeFixed;
+ bool isDecompressionFallbackFixed;
+ bool isRuntimeVersionFixed;
+ GetSettingsFixed(out isRuntimeVersionFixed, out isLinkTargetFixed, out isMemorySizeFixed, out isDecompressionFallbackFixed);
+ bool isAllFixed = isRuntimeVersionFixed && isLinkTargetFixed && isMemorySizeFixed && isDecompressionFallbackFixed;
+
+ if (!isAllFixed)
+ {
+ SettingsWindow.Open();
+ }
+ }
+
+ internal static void GetSettingsFixed(out bool isRuntimeVersionFixed, out bool isLinkTargetFixed, out bool isMemorySizeFixed, out bool isDecompressionFallbackFixed)
+ {
+ isRuntimeVersionFixed = true;
+ isLinkTargetFixed = true;
+ isMemorySizeFixed = true;
+ isDecompressionFallbackFixed = true;
+
+#if UNITY_2018_1_OR_NEWER
+ isLinkTargetFixed = PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Both;
+#endif
+
+#if !UNITY_2019_3_OR_NEWER
+ isRuntimeVersionFixed = PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest;
+#endif
+
+#if UNITY_2019_1_OR_NEWER
+ isMemorySizeFixed = PlayerSettings.WebGL.memorySize >= 16;
+#endif
+
+#if UNITY_2020_1_OR_NEWER
+ isDecompressionFallbackFixed = PlayerSettings.WebGL.decompressionFallback;
+#endif
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Scripts/Editor/VersionChecker.cs.meta b/Scripts/Editor/SettingsWindow.cs.meta
similarity index 83%
rename from Scripts/Editor/VersionChecker.cs.meta
rename to Scripts/Editor/SettingsWindow.cs.meta
index 762c9099..ff291d9b 100644
--- a/Scripts/Editor/VersionChecker.cs.meta
+++ b/Scripts/Editor/SettingsWindow.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: eaa5f470aa7fe422da0f1a17b59273a6
+guid: 7c42d421cc4c34f3eae1fbd67f0dced0
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Scripts/Editor/VersionChecker.cs b/Scripts/Editor/VersionChecker.cs
deleted file mode 100644
index b10fde9b..00000000
--- a/Scripts/Editor/VersionChecker.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using UnityEditor;
-using UnityEngine;
-using UnityEngine.Networking;
-
-namespace UnityWebSocket.Editor
-{
- public class VersionChecker
- {
-#if UNITY_2018_1_OR_NEWER
- static UnityWebRequest req;
- static bool forceCheck = false;
-
- [InitializeOnLoadMethod]
- public static void OnInit()
- {
- forceCheck = false;
- BeginCheck();
- }
-
- private static void Update()
- {
- if (req == null || req.isNetworkError || req.isHttpError)
- {
- EditorApplication.update -= Update;
- return;
- }
-
- if (req.isDone)
- {
- EditorApplication.update -= Update;
- var latestVersion = req.url.Substring(req.url.LastIndexOf("/v") + 2);
- var vKey = "UnityWebSocket_Version_Skip_v" + latestVersion;
- if (!forceCheck && EditorPrefs.GetBool(vKey, false))
- return;
-
- if (EditorPrefs.HasKey(vKey))
- {
- EditorPrefs.DeleteKey(vKey);
- }
-
- if (Settings.VERSION != latestVersion)
- {
- var text = req.downloadHandler.text;
- var st = text.IndexOf("content=\"v" + latestVersion);
- st = st > 0 ? text.IndexOf("\n", st) : -1;
- var end = st > 0 ? text.IndexOf("\" />", st) : -1;
- var changeLog = "";
- if (st > 0 && end > st)
- {
- changeLog = text.Substring(st + 1, end - st - 1).Trim();
- changeLog = changeLog.Replace("\r", "");
- changeLog = changeLog.Replace("\n", "\n- ");
- changeLog = "\nCHANGE LOG: \n- " + changeLog + "\n";
- }
-
- var code = EditorUtility.DisplayDialogComplex("UnityWebSocket"
- , "UnityWebSocket new version found v" + latestVersion
- + ", your current version is v" + Settings.VERSION + ".\n"
- + "Upgrade UnityWebSocket now?\n"
- + changeLog,
- "Upgrade Now", "Remind Me Later", "Skip this Version");
-
- if (code == 0)
- {
- Application.OpenURL(Settings.GITHUB + "/releases");
- }
- else if (code == 2)
- {
- EditorPrefs.SetBool(vKey, true);
- }
- }
- else if (forceCheck)
- {
- EditorUtility.DisplayDialog("UnityWebSocket", "Your current version v" + Settings.VERSION + " is the Latest version.", "OK");
- }
- }
- }
-
- [MenuItem("Tools/UnityWebSocket/Check Updates", priority = 10)]
- static void CheckUpdates()
- {
- forceCheck = true;
- BeginCheck();
- }
-
- static void BeginCheck()
- {
- req = UnityWebRequest.Get(Settings.GITHUB + "/releases/latest");
-
- EditorApplication.update -= Update;
- EditorApplication.update += Update;
-
- req.SendWebRequest();
- }
-#endif
- }
-}
\ No newline at end of file
diff --git a/Scripts/Editor/logo.png b/Scripts/Editor/logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..328d45b150d47af7976594ec3203bf0e696c9109
GIT binary patch
literal 8364
zcmcI~c{tSF`@gd9OP1_WN(`dx%kv;fWQ*}Op|Qsh22J+Io;_iZkR&mK8M2La#%_`=
z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*Kqa@w
zOG1;nF?@Y2RHLU7U0YhwcWA*6JH5kC#;pfXe;1zRVH@fSd|DGZ>2cK#ESkAjtA3U<
zYbHu=uKh74`lU;)$98Vmkg5uRp7e58t??<2klVsDe%?FIp5^(B*xjgz?a>zX5+b{m
z8*#o4u*+Y4dsr8+MIH%PeEQ($T1ije<%3`R^rV0T?0!QtLtd9!@qJVZ+3Jn!HDdw@TEECrcFm_Z%bVX?A+=a@l)uHZS>_ma$I_XcJfU1?q6~t>S-J0Wla&y45j|C-{25ib^
z!#*XXyuiMSOCtKNJMyUVlW&KhU22RdemkWAk_YP5hF#R7zlG#5Brlb}A+%tA7_&(Z
zmW>*vQR^DrzKo;_5!e3ul`AKa@2
z_I(J%h(ayG{l||tXInfjFrx2=LNg4)d0y@2)h7;WXgc0^V1Jti%Sxi`Z+)WuV?F$X
z86Krw40vv^)xF?gY1OxS&=Ude6G@Bj6BhD-T)j?hr4TY#t#G1P^=p`s<+jN@J~JW-e^zIQVB_Wdl*1pquB(V{7YktV*a!<>+&CSw~1-pbxjy
z6kD}Yl4YtS$NglVb@YAEfq&@CX<8cg)reLg+YK=Yn(WSWL=DS$dds=dg>}vx
zf~YlQB|jjR?071#4iA6^PfnUhx4X?Y^4^D0qjkdWL|8=8
z=!mq*eU_M+AEb6UtnB7_m_Sp-s^-{~;r3^4>y)+MPrlF8)D0H{!Sw4vTkI74Fa#|t
z;pLoqOZB1xt0pUJXb!(8^ka@rA#36gLV2RKm31z&>z(o)v76SKxa&?ITj3A7FNPOw
zeU=Pg3}-8(K_XwspC>}83u#D0CD5qW!*!z@&!8vAS00`FUw>Ho??BPl)~_j?;P3we
g{I`!{-*|p@PFMc=H+5g1zka(7^o(zp>p&y^2W&3U@c;k-
literal 0
HcmV?d00001
diff --git a/Scripts/Editor/logo.png.meta b/Scripts/Editor/logo.png.meta
new file mode 100644
index 00000000..d918ec18
--- /dev/null
+++ b/Scripts/Editor/logo.png.meta
@@ -0,0 +1,110 @@
+fileFormatVersion: 2
+guid: 9f70b2061753e4f30b3aa7964f10890d
+TextureImporter:
+ fileIDToRecycleName: {}
+ externalObjects: {}
+ serializedVersion: 9
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 0
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 2048
+ textureSettings:
+ serializedVersion: 2
+ filterMode: -1
+ aniso: 1
+ mipBias: -100
+ wrapU: 1
+ wrapV: 1
+ wrapW: -1
+ nPOTScale: 1
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 0
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 1
+ spriteTessellationDetail: -1
+ textureType: 2
+ textureShape: 1
+ singleChannelComponent: 0
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ platformSettings:
+ - serializedVersion: 2
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ - serializedVersion: 2
+ buildTarget: Standalone
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ - serializedVersion: 2
+ buildTarget: WebGL
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ physicsShape: []
+ bones: []
+ spriteID:
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ spritePackingTag:
+ pSDRemoveMatte: 0
+ pSDShowRemoveMatteOption: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index 981984b7..4ea17210 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -3,9 +3,12 @@
public static class Settings
{
public const string GITHUB = "https://github.com/psygame/UnityWebSocket";
- public const string QQ = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
+ public const string QQ_GROUP = "1126457634";
+ public const string QQ_GROUP_LINK = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
public const string EMAIL = "799329256@qq.com";
public const string AUHTOR = "psygame";
- public const string VERSION = "2.2.0";
+ public const string VERSION = "2.3.0";
+ public const string PACKAGE_NAME = "com.psygame.unitywebsocket";
+ public const string UPM_URL = "https://github.com/psygame/UnityWebSocket.git";
}
}
From efed262f64553d8c68f5d63479c517fc5d0030ae Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 18:35:54 +0800
Subject: [PATCH 17/66] fix latest version
---
Scripts/Editor/SettingsWindow.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 993ed3fd..a28c73a6 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -250,7 +250,7 @@ private void VersionCheckUpdate()
if (req.isDone)
{
EditorApplication.update -= VersionCheckUpdate;
- latestVersion = req.url.Substring(req.url.LastIndexOf("/v") + 2);
+ latestVersion = req.url.Substring(req.url.LastIndexOf("/") + 1);
if (Settings.VERSION != latestVersion)
{
From 3ee93e25bd4b7fb5d8e013823fbe1c4afcd7961c Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 18:48:20 +0800
Subject: [PATCH 18/66] fix logo, fix linkerTarget
---
Scripts/Editor/SettingsWindow.cs | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index a28c73a6..2e4b673f 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -35,9 +35,17 @@ private void OnGUI()
private void DrawLogo()
{
- var logo = AssetDatabase.LoadAssetAtPath("Assets/UnityWebSocket/Scripts/Editor/logo.png");
- var logoPos = new Rect(10, 10, 66, 66);
- GUI.DrawTexture(logoPos, logo);
+ var logo = AssetDatabase.LoadAssetAtPath("Packages/UnityWebSocket/Scripts/Editor/logo.png");
+ if (logo == null)
+ {
+ logo = AssetDatabase.LoadAssetAtPath("Assets/UnityWebSocket/Scripts/Editor/logo.png");
+ }
+
+ if (logo != null)
+ {
+ var logoPos = new Rect(10, 10, 66, 66);
+ GUI.DrawTexture(logoPos, logo);
+ }
var title = "UnityWebSocket";
var titlePos = new Rect(80, 28, 500, 50);
@@ -299,7 +307,7 @@ internal static void GetSettingsFixed(out bool isRuntimeVersionFixed, out bool i
isDecompressionFallbackFixed = true;
#if UNITY_2018_1_OR_NEWER
- isLinkTargetFixed = PlayerSettings.WebGL.linkerTarget == WebGLLinkerTarget.Both;
+ isLinkTargetFixed = PlayerSettings.WebGL.linkerTarget == (WebGLLinkerTarget)2;
#endif
#if !UNITY_2019_3_OR_NEWER
From de2c8706e53b2e1554966027ab2c905dd73fd0eb Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 18:52:29 +0800
Subject: [PATCH 19/66] fix draft version
---
Scripts/Editor/SettingsWindow.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 2e4b673f..644e5798 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -263,7 +263,7 @@ private void VersionCheckUpdate()
if (Settings.VERSION != latestVersion)
{
var text = req.downloadHandler.text;
- var st = text.IndexOf("content=\"v" + latestVersion);
+ var st = text.IndexOf("content=\"" + latestVersion);
st = st > 0 ? text.IndexOf("\n", st) : -1;
var end = st > 0 ? text.IndexOf("\" />", st) : -1;
if (st > 0 && end > st)
From 57e2cda1b1e842565bab7a937b40f5b3b49b5fbe Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 18:59:24 +0800
Subject: [PATCH 20/66] fix update index
---
Scripts/Editor/SettingsWindow.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 644e5798..8f6059a3 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -119,7 +119,7 @@ private void UpdateVersion()
if (index != -1)
{
var end_index = txt.IndexOf(",", index);
- var old_str = txt.Substring(index, end_index);
+ var old_str = txt.Substring(index, end_index - index);
var new_str = string.Format("\"{0}\": \"{1}#{2}\"", Settings.PACKAGE_NAME, Settings.UPM_URL, Settings.VERSION);
txt = txt.Replace(old_str, new_str);
File.WriteAllText(packagePath, txt);
From 9904292a06961c824141394837e4ec6fcb68a985 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 19:06:02 +0800
Subject: [PATCH 21/66] fix latest version
---
Scripts/Editor/SettingsWindow.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 8f6059a3..c4f73ba7 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -120,7 +120,7 @@ private void UpdateVersion()
{
var end_index = txt.IndexOf(",", index);
var old_str = txt.Substring(index, end_index - index);
- var new_str = string.Format("\"{0}\": \"{1}#{2}\"", Settings.PACKAGE_NAME, Settings.UPM_URL, Settings.VERSION);
+ var new_str = string.Format("\"{0}\": \"{1}#{2}\"", Settings.PACKAGE_NAME, Settings.UPM_URL, latestVersion);
txt = txt.Replace(old_str, new_str);
File.WriteAllText(packagePath, txt);
AssetDatabase.Refresh();
From cbcc6afd5c9b27898058f34368c8116806b4301f Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 22:04:14 +0800
Subject: [PATCH 22/66] fix logo read
---
Scripts/Editor/SettingsWindow.cs | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index c4f73ba7..2e61e6c9 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -35,18 +35,19 @@ private void OnGUI()
private void DrawLogo()
{
- var logo = AssetDatabase.LoadAssetAtPath("Packages/UnityWebSocket/Scripts/Editor/logo.png");
- if (logo == null)
- {
- logo = AssetDatabase.LoadAssetAtPath("Assets/UnityWebSocket/Scripts/Editor/logo.png");
- }
+ var logoPath = Path.Combine(Application.dataPath, "../Packages/UnityWebSocket/Scripts/Editor/logo.png");
+ if (!File.Exists(logoPath))
+ logoPath = Path.Combine(Application.dataPath, "UnityWebSocket/Scripts/Editor/logo.png");
- if (logo != null)
+ if (File.Exists(logoPath))
{
+ var logo = new Texture2D(1200, 1200);
+ logo.LoadImage(File.ReadAllBytes(logoPath));
var logoPos = new Rect(10, 10, 66, 66);
GUI.DrawTexture(logoPos, logo);
}
+
var title = "UnityWebSocket";
var titlePos = new Rect(80, 28, 500, 50);
GUI.Label(titlePos, title, TextStyle(24));
From 25d9ba887e3695231ac3526b063eda6103817b34 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Thu, 20 Aug 2020 23:04:05 +0800
Subject: [PATCH 23/66] base64 icon
---
Scripts/Editor/SettingsWindow.cs | 39 +++++++----
Scripts/Editor/logo.png | Bin 8364 -> 0 bytes
Scripts/Editor/logo.png.meta | 110 -------------------------------
3 files changed, 27 insertions(+), 122 deletions(-)
delete mode 100644 Scripts/Editor/logo.png
delete mode 100644 Scripts/Editor/logo.png.meta
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 2e61e6c9..84020e1c 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -2,6 +2,7 @@
using UnityEditor;
using UnityEngine.Networking;
using System.IO;
+using System;
namespace UnityWebSocket.Editor
{
@@ -35,18 +36,10 @@ private void OnGUI()
private void DrawLogo()
{
- var logoPath = Path.Combine(Application.dataPath, "../Packages/UnityWebSocket/Scripts/Editor/logo.png");
- if (!File.Exists(logoPath))
- logoPath = Path.Combine(Application.dataPath, "UnityWebSocket/Scripts/Editor/logo.png");
-
- if (File.Exists(logoPath))
- {
- var logo = new Texture2D(1200, 1200);
- logo.LoadImage(File.ReadAllBytes(logoPath));
- var logoPos = new Rect(10, 10, 66, 66);
- GUI.DrawTexture(logoPos, logo);
- }
-
+ var logo = new Texture2D(1200, 1200);
+ logo.LoadImage(Convert.FromBase64String(LOGO_BASE64.VALUE));
+ var logoPos = new Rect(10, 10, 66, 66);
+ GUI.DrawTexture(logoPos, logo);
var title = "UnityWebSocket";
var titlePos = new Rect(80, 28, 500, 50);
@@ -325,4 +318,26 @@ internal static void GetSettingsFixed(out bool isRuntimeVersionFixed, out bool i
}
}
+
+ internal static class LOGO_BASE64
+ {
+ public const string VALUE = "iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAMAAADUivDaAAAAq1BMVEUAAABKmtcvjtYzl" +
+ "9szmNszl9syl9k0mNs0mNwzmNs0mNszl9szl9s0mNs0mNwzmNw0mNwyltk0mNw0mNwzl9s0mNsymNs0mNszmNwzmNwzm" +
+ "NszmNs0mNwzl9w0mNwzmNw0mNs0mNs0mNwzl9wzmNs0mNwzmNs0mNwzl90zmNszmNszl9szmNsxmNszmNszmNw0mNwzm" +
+ "Nw0mNs2neM4pe41mt43ouo2oOY5qfM+UHlaAAAAMnRSTlMAAwXN3sgI+/069MSCK6M/MA74h9qfFHB8STWMJ9OSdmNcI" +
+ "8qya1IeF+/U0EIa57mqmFTYJe4AAAN3SURBVFjD7ZbpkppAFEa/bgVBREF2kEVGFNeZsM77P1kadURnJkr8k1Qlx1Khu" +
+ "/pw7+2lwH/+YcgfMBBLG7VocwDamzH+wJBB8Qhjve2f0TdrGwjei6o4Ub/nM/APw5Z7vvSB/qrCrqbD6fBEVtigeMxks" +
+ "fX9zWbj+z1jhqgSBplQ50eGo4614WXlRAzgrRhmtSfvxAn7pB0N5ObaKKZZuU5/d37IBcBgUQwqDuf7Z2gUmVAl4NGNr" +
+ "/UeHxV5n39ulbaKLI86h6HilmM5M1aN126lpNhtl59yeTsp8nUMvpNC1J3bh5FtfVRk+bJrJunn5d4U4piJ/Vw9eXgsj" +
+ "4ZpZaCjg9waZkIpnBWLJ44OwoNu60F2UnSaEkKv4XnAlCpm6B4F/aKMDiyGi2L8SEEAVdxNLuzmgV7nFwObEe2xQVuX+" +
+ "RV1lWetga3w+cN1sXgvm4cJH8OEgZC1DPKhfF/BIymmQrMjq/x65FUeEkDup8GxoexZmznHCvANtXU/CAq13yimhQGtm" +
+ "H4VCPnBBL1fTKo3CqEcvq7Lb/OwHxWTYlyw+JmjKoVvDLVOQB4pVsM8K8smgvLCxZDlIijwyOEc+nr/msMwK0+GQWGBd" +
+ "tmhjv8icTds1s2ammaFh04QLLe69NK7guP6mTDMaw3o6nAX/Z7EXUskPSvWEWg4srVlp5NTDXv9Lce9HGN5eeG4nj5Yz" +
+ "ACteU2wQLo4MBtJfd1nw5nG1/s9zwUQ6pykL1TQjqdeuvQW0naz2XKLYL4Cwzr4vj+OQdD96CSp7Lrynp4aeFF0xdm5q" +
+ "6OFtFfPv7URxpWJNjd/N+3+I9+1klMav12Qtgbt9R2JaIopjkzaPtOFq4KxUpqfUMSFnQrySWjLoQzRZS4HMH84ME1ej" +
+ "S1YJpQZ3B+sR1uCQJSBdGdCk1eAEgORR88KK05W8dh2MA+A/SKCYu3mCJ0Ek7HBx4HHeuwYy5G3x8hSMTJcOMFbinCsn" +
+ "hO1V1aszGULvA0g4UFsb4VA0hAFcyo6cgLsAoT7uUtGAH5wQKQle0wuLyxLTaNyJEYwxw4wSljLK1TP8CAaOyhBMMEsj" +
+ "OBoXgo7VGElFkSWL+vef1RF2YNXeRWYzQBTpkhC8KaZHhuIogArkQLKClBZjU26B2IZgGz+cpZkHl8g3fYUaW/YP2kb2" +
+ "M/V97JY/vZN859n+QmO7XtC9Bf2jAAAAABJRU5ErkJggg==";
+ }
}
\ No newline at end of file
diff --git a/Scripts/Editor/logo.png b/Scripts/Editor/logo.png
deleted file mode 100644
index 328d45b150d47af7976594ec3203bf0e696c9109..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 8364
zcmcI~c{tSF`@gd9OP1_WN(`dx%kv;fWQ*}Op|Qsh22J+Io;_iZkR&mK8M2La#%_`=
zV<%)CO9*BCPCcLBb^Wf-pWo~H&UKyldEKx3b>HXQ=gge`m9U>OjJ})
zn^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GZ>2cK#ESkAjtA3U<
zYbHu=uKh74`lU;)$98Vmkg5uRp7e58t??<2klVsDe%?FIp5^(B*xjgz?a>zX5+b{m
z8*#o4u*+Y4dsr8+MIH%PeEQ($T1ije<%3`R^rV0T?0!QtLtd9!@qJVZ+3Jn!HDdw@TEECrcFm_Z%bVX?A+=a@l)uHZS>_ma$I_XcJfU1?q6~t>S-J0Wla&y45j|C-{25ib^
z!#*XXyuiMSOCtKNJMyUVlW&KhU22RdemkWAk_YP5hF#R7zlG#5Brlb}A+%tA7_&(Z
zmW>*vQR^DrzKo;_5!e3ul`AKa@2
z_I(J%h(ayG{l||tXInfjFrx2=LNg4)d0y@2)h7;WXgc0^V1Jti%Sxi`Z+)WuV?F$X
z86Krw40vv^)xF?gY1OxS&=Ude6G@Bj6BhD-T)j?hr4TY#t#G1P^=p`s<+jN@J~JW-e^zIQVB_Wdl*1pquB(V{7YktV*a!<>+&CSw~1-pbxjy
z6kD}Yl4YtS$NglVb@YAEfq&@CX<8cg)reLg+YK=Yn(WSWL=DS$dds=dg>}vx
zf~YlQB|jjR?071#4iA6^PfnUhx4X?Y^4^D0qjkdWL|8=8
z=!mq*eU_M+AEb6UtnB7_m_Sp-s^-{~;r3^4>y)+MPrlF8)D0H{!Sw4vTkI74Fa#|t
z;pLoqOZB1xt0pUJXb!(8^ka@rA#36gLV2RKm31z&>z(o)v76SKxa&?ITj3A7FNPOw
zeU=Pg3}-8(K_XwspC>}83u#D0CD5qW!*!z@&!8vAS00`FUw>Ho??BPl)~_j?;P3we
g{I`!{-*|p@PFMc=H+5g1zka(7^o(zp>p&y^2W&3U@c;k-
diff --git a/Scripts/Editor/logo.png.meta b/Scripts/Editor/logo.png.meta
deleted file mode 100644
index d918ec18..00000000
--- a/Scripts/Editor/logo.png.meta
+++ /dev/null
@@ -1,110 +0,0 @@
-fileFormatVersion: 2
-guid: 9f70b2061753e4f30b3aa7964f10890d
-TextureImporter:
- fileIDToRecycleName: {}
- externalObjects: {}
- serializedVersion: 9
- mipmaps:
- mipMapMode: 0
- enableMipMap: 0
- sRGBTexture: 1
- linearTexture: 0
- fadeOut: 0
- borderMipMap: 0
- mipMapsPreserveCoverage: 0
- alphaTestReferenceValue: 0.5
- mipMapFadeDistanceStart: 1
- mipMapFadeDistanceEnd: 3
- bumpmap:
- convertToNormalMap: 0
- externalNormalMap: 0
- heightScale: 0.25
- normalMapFilter: 0
- isReadable: 0
- streamingMipmaps: 0
- streamingMipmapsPriority: 0
- grayScaleToAlpha: 0
- generateCubemap: 6
- cubemapConvolution: 0
- seamlessCubemap: 0
- textureFormat: 1
- maxTextureSize: 2048
- textureSettings:
- serializedVersion: 2
- filterMode: -1
- aniso: 1
- mipBias: -100
- wrapU: 1
- wrapV: 1
- wrapW: -1
- nPOTScale: 1
- lightmap: 0
- compressionQuality: 50
- spriteMode: 0
- spriteExtrude: 1
- spriteMeshType: 1
- alignment: 0
- spritePivot: {x: 0.5, y: 0.5}
- spritePixelsToUnits: 100
- spriteBorder: {x: 0, y: 0, z: 0, w: 0}
- spriteGenerateFallbackPhysicsShape: 1
- alphaUsage: 1
- alphaIsTransparency: 1
- spriteTessellationDetail: -1
- textureType: 2
- textureShape: 1
- singleChannelComponent: 0
- maxTextureSizeSet: 0
- compressionQualitySet: 0
- textureFormatSet: 0
- platformSettings:
- - serializedVersion: 2
- buildTarget: DefaultTexturePlatform
- maxTextureSize: 2048
- resizeAlgorithm: 0
- textureFormat: -1
- textureCompression: 1
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- androidETC2FallbackOverride: 0
- - serializedVersion: 2
- buildTarget: Standalone
- maxTextureSize: 2048
- resizeAlgorithm: 0
- textureFormat: -1
- textureCompression: 1
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- androidETC2FallbackOverride: 0
- - serializedVersion: 2
- buildTarget: WebGL
- maxTextureSize: 2048
- resizeAlgorithm: 0
- textureFormat: -1
- textureCompression: 1
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- androidETC2FallbackOverride: 0
- spriteSheet:
- serializedVersion: 2
- sprites: []
- outline: []
- physicsShape: []
- bones: []
- spriteID:
- vertices: []
- indices:
- edges: []
- weights: []
- spritePackingTag:
- pSDRemoveMatte: 0
- pSDShowRemoveMatteOption: 0
- userData:
- assetBundleName:
- assetBundleVariant:
From 899e26f9e925629d9998f111e9474b3326743735 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 12:55:44 +0800
Subject: [PATCH 24/66] add logo
---
Scripts/Editor/logo.png | Bin 0 -> 8364 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 Scripts/Editor/logo.png
diff --git a/Scripts/Editor/logo.png b/Scripts/Editor/logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..328d45b150d47af7976594ec3203bf0e696c9109
GIT binary patch
literal 8364
zcmcI~c{tSF`@gd9OP1_WN(`dx%kv;fWQ*}Op|Qsh22J+Io;_iZkR&mK8M2La#%_`=
zV<%)CO9*BCPCcLBb^Wf-pWo~H&UKyldEKx3b>HXQ=gge`m9U>OjJ})
zn^RHIV173mY6`>8UVcpJXk4}LYg18SQ<#tKX({$OUvqsOs`Af5s}zIF)W||l-`nVB
z=H$(+NrlWQ%Jo*(WaY#?2*pe5XKws}>QlJJN}GftD;3oxDudhF7SATur~BZOcLZon
z6Vmt7Z%qwXRu{|onphEcSL6XCv=yNlJfuf
zu@?Ba^>qBNMO>$-p^DuC?p$sE>2>y^^K%!q0J1m`!NWk(#^82qVxhV2-_}sxi6Uqs
zh2FcM)PKxhYZWE*M&X0UT-DrYtyjQ5BeU$4@X)IP&t^`yN`<
zdh~+jM5x8HM{>a1!Jxfnw+f-X+pbYDe#6kwH_t>b0S)`TW+y8QdZgwKTEnD~u-O5q
zYN_YNH(t+ho^|LfX;0mQkT%cA#SeUG^eci&tjI#PXlkRa23|f;Ea9~HfR1RE@`g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hD-T)j?hr4TY#t#G1P^=p`s<+jN@J~JW-e^zIQVB_Wdl*1pquB(V{7YktV*a!<>+&CSw~1-pbxjy
z6kD}Yl4YtS$NglVb@YAEfq&@CX<8cg)reLg+YK=Yn(WSWL=DS$dds=dg>}vx
zf~YlQB|jjR?071#4iA6^PfnUhx4X?Y^4^D0qjkdWL|8=8
z=!mq*eU_M+AEb6UtnB7_m_Sp-s^-{~;r3^4>y)+MPrlF8)D0H{!Sw4vTkI74Fa#|t
z;pLoqOZB1xt0pUJXb!(8^ka@rA#36gLV2RKm31z&>z(o)v76SKxa&?ITj3A7FNPOw
zeU=Pg3}-8(K_XwspC>}83u#D0CD5qW!*!z@&!8vAS00`FUw>Ho??BPl)~_j?;P3we
g{I`!{-*|p@PFMc=H+5g1zka(7^o(zp>p&y^2W&3U@c;k-
literal 0
HcmV?d00001
From 24785ed4466aad33343013deb656218f265aa091 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 13:09:00 +0800
Subject: [PATCH 25/66] remove logo
---
Scripts/Editor/logo.png | Bin 8364 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 Scripts/Editor/logo.png
diff --git a/Scripts/Editor/logo.png b/Scripts/Editor/logo.png
deleted file mode 100644
index 328d45b150d47af7976594ec3203bf0e696c9109..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 8364
zcmcI~c{tSF`@gd9OP1_WN(`dx%kv;fWQ*}Op|Qsh22J+Io;_iZkR&mK8M2La#%_`=
zV<%)CO9*BCPCcLBb^Wf-pWo~H&UKyldEKx3b>HXQ=gge`m9U>OjJ})
zn^RHIV173mY6`>8UVcpJXk4}LYg18SQ<#tKX({$OUvqsOs`Af5s}zIF)W||l-`nVB
z=H$(+NrlWQ%Jo*(WaY#?2*pe5XKws}>QlJJN}GftD;3oxDudhF7SATur~BZOcLZon
z6Vmt7Z%qwXRu{|onphEcSL6XCv=yNlJfuf
zu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bVX?A+=a@l)uHZS>_ma$I_XcJfU1?q6~t>S-J0Wla&y45j|C-{25ib^
z!#*XXyuiMSOCtKNJMyUVlW&KhU22RdemkWAk_YP5hF#R7zlG#5Brlb}A+%tA7_&(Z
zmW>*vQR^DrzKo;_5!e3ul`AKa@2
z_I(J%h(ayG{l||tXInfjFrx2=LNg4)d0y@2)h7;WXgc0^V1Jti%Sxi`Z+)WuV?F$X
z86Krw40vv^)xF?gY1OxS&=Ude6G@Bj6BhD-T)j?hr4TY#t#G1P^=p`s<+jN@J~JW-e^zIQVB_Wdl*1pquB(V{7YktV*a!<>+&CSw~1-pbxjy
z6kD}Yl4YtS$NglVb@YAEfq&@CX<8cg)reLg+YK=Yn(WSWL=DS$dds=dg>}vx
zf~YlQB|jjR?071#4iA6^PfnUhx4X?Y^4^D0qjkdWL|8=8
z=!mq*eU_M+AEb6UtnB7_m_Sp-s^-{~;r3^4>y)+MPrlF8)D0H{!Sw4vTkI74Fa#|t
z;pLoqOZB1xt0pUJXb!(8^ka@rA#36gLV2RKm31z&>z(o)v76SKxa&?ITj3A7FNPOw
zeU=Pg3}-8(K_XwspC>}83u#D0CD5qW!*!z@&!8vAS00`FUw>Ho??BPl)~_j?;P3we
g{I`!{-*|p@PFMc=H+5g1zka(7^o(zp>p&y^2W&3U@c;k-
From 2b5de0f7216f3f0f5239f0350e66bc41a35ff511 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 14:04:16 +0800
Subject: [PATCH 26/66] new readme
---
README.md | 74 ++++++++++++++++++++++---------------------------------
1 file changed, 29 insertions(+), 45 deletions(-)
diff --git a/README.md b/README.md
index ac5bcd8f..7c0a0d02 100644
--- a/README.md
+++ b/README.md
@@ -1,29 +1,35 @@
[(English)](README_EN.md)
-## 在线示例
+
+

+
-- [http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)
+## **在线示例**
-## 安装
+- **[http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)**
-#### 需要
+
+## **快速开始**
+
+#### 安装环境
- Unity 2018.3 或更高。
- 无其他SDK依赖。
-#### 使用 OpenUPM 安装
-- SDK已上传至 [OpenUPM](https://openupm.com).
-您可以使用 [openupm-cli](https://github.com/openupm/openupm-cli) 进行安装。
+#### 安装方法
+
+- **通过 OpenUPM 安装**
+
+ 插件已托管至 [OpenUPM](https://openupm.com) ,您可以使用 [openupm-cli](https://github.com/openupm/openupm-cli) 进行安装。
```
openupm add com.psygame.unitywebsocket
```
+- **通过 Git 安装**
-#### 使用 Git 安装
-
-- 在您的项目根路径的 Packages 文件夹中找到 manifest.json 文件,参考如下方式进行修改:
+ 在您的项目根路径的 `Packages` 文件夹中找到 `manifest.json` 文件,参考如下方式进行修改:
```js
{
"dependencies": {
@@ -33,28 +39,19 @@
}
```
-- 可通过修改链接后缀 `#{version}` 来安装对应版本.
- * 示例: `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.2.0",`
-
-
-- 或使用 [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) 来安装SDK。
-
-#### 使用 Unity Package 安装
-
-- 在 [Releases](https://github.com/psygame/UnityWebSocket/releases) 页面中,下载对应版本的 UnityWebSocket.unitypackage 安装包。
-- 在您的项目中导入安装包。
+ 可通过修改链接后缀 `#{version}` 来安装对应版本。
+ 示例: `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.3.0",`
-## 使用方法
+- **通过 Unity Package 安装**
-- 需要如下设置:
+ 在 [Releases](https://github.com/psygame/UnityWebSocket/releases) 页面中,下载对应版本的 `UnityWebSocket.unitypackage` 安装包,然后导入到您的项目中。
- * 需要 Scripting Runtime Version = .Net 4.x
- * 需要 WebGL LinkerTarger = asm.js or Both
-- 使用 WebSocket
+#### 使用方法
- ```csharp
+- 代码示例
+```csharp
// 命名空间
using UnityWebSocket;
@@ -81,9 +78,11 @@
- 详细使用方法可参考项目中的 [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) 示例代码。
-#### 3. 注意(Warning)
-- 插件中多个命名空间中存在 **WebSocket** 类,适用不同环境。
+
+#### 注意(Warning)
+
+- 插件中多个命名空间中存在 **WebSocket** 类,适用不同环境,请根据自身需求选择。
命名空间 | 平台 | 方式 | 说明
-|-|-|-
@@ -92,20 +91,5 @@
UnityWebSocket.WebGL | WebGL平台 | 异步 | 仅支持WebGL平台下的通信。
UnityWebSocket.NoWebGL | 非WebGL平台 | 异步 | 仅支持非WebGL平台下的通信。
-#### 4. WebGL 模块说明
-
-- WebSocket.jslib 语法格式需要遵循 [asm.js](http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html)。
-
- 路径:Plugins/WebGL/WebSocket.jslib
- 作用:Unity发布WebGL版本会将其加入到js运行库中。
-
-- Example 场景
-
- 作用:WebSocket的使用方法示例。
-
-#### 5. WebSocket 服务器
-
-- 使用官方提供的 Echo Test 服务器。参考 [Echo Test](http://www.websocket.org/echo.html)。
-
-#### 6. QQ 交流群
-- 1126457634 >>> [入群通道](https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd) <<<
+#### QQ 交流群
+- 1126457634 >>> [入群通道](https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd) <<<
From 2de13c78bc9ac7f1dc12eae6a9345f14a2024949 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 14:06:34 +0800
Subject: [PATCH 27/66] fix readme
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7c0a0d02..e0317a43 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[(English)](README_EN.md)
-

+
## **在线示例**
From cad86dad3447831536ea3bc7ac7980bbdb2237c9 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 14:26:08 +0800
Subject: [PATCH 28/66] fix readme_en
---
README.md | 2 +-
README_EN.md | 59 ++++++++++++++++++++--------------------------------
2 files changed, 23 insertions(+), 38 deletions(-)
diff --git a/README.md b/README.md
index e0317a43..978bc121 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@
```
可通过修改链接后缀 `#{version}` 来安装对应版本。
- 示例: `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.3.0",`
+ * 示例: `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.3.0",`
- **通过 Unity Package 安装**
diff --git a/README_EN.md b/README_EN.md
index 55105056..49ce7fd0 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -1,28 +1,34 @@
[(中文版)](README.md)
-## Online Demo
+
+

+
-- [http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)
+## **Online Demo**
-## Installation
+- **[http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)**
-#### Requirement
+
+## **Quick Start**
+
+#### Requirements
- Unity 2018.3 or later
- No other SDK are required
-#### Using OpenUPM
+#### Installation
+
+- **Using OpenUPM**
-- This package is available on [OpenUPM](https://openupm.com).
-You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
+ This package is available on [OpenUPM](https://openupm.com). You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
```
openupm add com.psygame.unitywebsocket
```
-#### Using Git
+- **Using Git**
-- Find the manifest.json file in the Packages folder of your project and edit it to look like this:
+ Find the manifest.json file in the Packages folder of your project and edit it to look like this:
```js
{
"dependencies": {
@@ -32,25 +38,19 @@ You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
}
```
-- To update the package, change suffix `#{version}` to the target version.
- * e.g. `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.2.0",`
+ To update the package, change suffix `#{version}` to the target version.
+ * e.g. `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.3.0",`
-- Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) to install and update the package.
-#### Using Unity Package
+- **Using Unity Package**
-- Download a UnityWebSocket.unitypackage file from [Releases](https://github.com/psygame/UnityWebSocket/releases) page.
-- Import it into your Unity project.
+ Download an `UnityWebSocket.unitypackage` file from [Releases](https://github.com/psygame/UnityWebSocket/releases) page.
+ Import it into your Unity project.
-## Usage:
+#### Usage:
-- Require Settings:
-
- * Require Scripting Runtime Version = .Net 4.x
- * Require WebGL LinkerTarger = asm.js or Both
-
-- Easy to use WebSocket
+- Easy to use
```csharp
// the namespace
@@ -89,18 +89,3 @@ You can install it via [openupm-cli](https://github.com/openupm/openupm-cli).
UnityWebSocket.Uniform | all | asynchronized | consider the problem by using unity component in asynchronized callback.
UnityWebSocket.WebGL | WebGL only | asynchronized | only run in WebGL platform.
UnityWebSocket.NoWebGL | WebGL except | asynchronized | only run in not WebGL platforms.
-
-#### 4. WebGL Module Introduction
-
-- WebSocket.jslib, syntax follow to [asm.js](http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html)。
-
- Path: Plugins/WebGL/WebSocket.jslib
- Fucntion:Unity will deploy it to web js runtime on WebGL platform.
-
-- Example Scene
-
- Function: Example how to use UnityWebSocket.
-
-#### 5. WebSocket Server
-
-- use Official Echo Test Server. refer to [Echo Test](http://www.websocket.org/echo.html).
From 3c9f01eaf3559c50c547845663d33fb87d28dd0c Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 14:40:40 +0800
Subject: [PATCH 29/66] settings 2.3.1
---
Scripts/Runtime/Core/Settings.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index 4ea17210..dc903c94 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -7,7 +7,7 @@ public static class Settings
public const string QQ_GROUP_LINK = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
public const string EMAIL = "799329256@qq.com";
public const string AUHTOR = "psygame";
- public const string VERSION = "2.3.0";
+ public const string VERSION = "2.3.1";
public const string PACKAGE_NAME = "com.psygame.unitywebsocket";
public const string UPM_URL = "https://github.com/psygame/UnityWebSocket.git";
}
From 440600ab4511a59010cd8ad63baa5f4dc51b4ccd Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 14:47:41 +0800
Subject: [PATCH 30/66] openupm Badge
---
README.md | 2 ++
README_EN.md | 2 ++
2 files changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 978bc121..ec3cda0a 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,8 @@
+[](https://openupm.com/packages/com.psygame.unitywebsocket/)
+
## **在线示例**
- **[http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)**
diff --git a/README_EN.md b/README_EN.md
index 49ce7fd0..593d7952 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -5,6 +5,8 @@
+[](https://openupm.com/packages/com.psygame.unitywebsocket/)
+
## **Online Demo**
- **[http://39.105.150.229/UnityWebSocket/](http://39.105.150.229/UnityWebSocket/)**
From f772328322b438a7a3962fa128a8796e5703487d Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Fri, 21 Aug 2020 14:53:11 +0800
Subject: [PATCH 31/66] package json
---
package.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index 519d2c30..7ba34ebe 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
{
"name": "com.psygame.unitywebsocket",
"displayName": "UnityWebSocket",
- "version": "2.2.0",
- "unity": "2018.1",
+ "version": "2.3.1",
+ "unity": "2018.3",
"description": "The Best Unity WebSocket Plugin for All Platforms.",
"keywords": [ "websocket", "webgl", "socket", "jslib" ],
"category": "network",
From dea8b8d7e9c6c16c90f8c08001ceeb26c4e3abfe Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Mon, 24 Aug 2020 13:33:45 +0800
Subject: [PATCH 32/66] v2.3.2 Change Log - OpenUpm Update + - Check Update
Error Handle + - Fix Demo Scene Folder + - Readme Blod + - Fix Change Log + -
Version 2.3.2 +
---
README.md | 10 +++----
README_EN.md | 8 +++---
Samples~/{ => Demo}/Demo.unity | 0
Scripts/Editor/SettingsWindow.cs | 47 ++++++++++++++++++++++++--------
Scripts/Runtime/Core/Settings.cs | 2 +-
5 files changed, 45 insertions(+), 22 deletions(-)
rename Samples~/{ => Demo}/Demo.unity (100%)
diff --git a/README.md b/README.md
index ec3cda0a..33b5bb9e 100644
--- a/README.md
+++ b/README.md
@@ -14,13 +14,13 @@
## **快速开始**
-#### 安装环境
+#### **安装环境**
- Unity 2018.3 或更高。
- 无其他SDK依赖。
-#### 安装方法
+#### **安装方法**
- **通过 OpenUPM 安装**
@@ -50,7 +50,7 @@
在 [Releases](https://github.com/psygame/UnityWebSocket/releases) 页面中,下载对应版本的 `UnityWebSocket.unitypackage` 安装包,然后导入到您的项目中。
-#### 使用方法
+#### **使用方法**
- 代码示例
```csharp
@@ -82,7 +82,7 @@
-#### 注意(Warning)
+#### **注意(Warning)**
- 插件中多个命名空间中存在 **WebSocket** 类,适用不同环境,请根据自身需求选择。
@@ -93,5 +93,5 @@
UnityWebSocket.WebGL | WebGL平台 | 异步 | 仅支持WebGL平台下的通信。
UnityWebSocket.NoWebGL | 非WebGL平台 | 异步 | 仅支持非WebGL平台下的通信。
-#### QQ 交流群
+#### **QQ 交流群**
- 1126457634 >>> [入群通道](https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd) <<<
diff --git a/README_EN.md b/README_EN.md
index 593d7952..11fc94ff 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -14,12 +14,12 @@
## **Quick Start**
-#### Requirements
+#### **Requirements**
- Unity 2018.3 or later
- No other SDK are required
-#### Installation
+#### **Installation**
- **Using OpenUPM**
@@ -50,7 +50,7 @@
Import it into your Unity project.
-#### Usage:
+#### **Usage**
- Easy to use
@@ -81,7 +81,7 @@
- more detail usage, see the [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) code in project。
-#### 3. Attention(Warning)
+#### **Attention(Warning)**
- there are many **WebSocket** class in different namespace, use in different situations.
diff --git a/Samples~/Demo.unity b/Samples~/Demo/Demo.unity
similarity index 100%
rename from Samples~/Demo.unity
rename to Samples~/Demo/Demo.unity
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 84020e1c..20dec66b 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -6,11 +6,11 @@
namespace UnityWebSocket.Editor
{
- public class SettingsWindow : EditorWindow
+ internal class SettingsWindow : EditorWindow
{
static SettingsWindow window = null;
[MenuItem("Tools/UnityWebSocket", priority = 1)]
- public static void Open()
+ internal static void Open()
{
if (window != null)
{
@@ -67,10 +67,14 @@ private void DrawVersion()
if (string.IsNullOrEmpty(latestVersion))
{
GUI.Label(new Rect(440, 30, 150, 10), "Checking Update...", TextStyle(alignment: TextAnchor.MiddleCenter));
+ }
+ else if (latestVersion == "unknown")
+ {
+
}
else
{
- GUI.Label(new Rect(440, 30, 150, 10), "Latest Version: " + latestVersion, TextStyle(alignment: TextAnchor.MiddleCenter));
+ GUI.Label(new Rect(440, 30, 150, 10), " Latest Version: " + latestVersion, TextStyle(alignment: TextAnchor.MiddleCenter));
if (Settings.VERSION == latestVersion)
{
if (GUI.Button(new Rect(440, 50, 150, 18), "Check Update"))
@@ -104,26 +108,43 @@ private void ShowUpdateDialog()
private void UpdateVersion()
{
- // via git
var packagePath = Path.Combine(Application.dataPath, "../Packages/manifest.json");
if (File.Exists(packagePath))
{
var txt = File.ReadAllText(packagePath);
- var index = txt.IndexOf("\"" + Settings.PACKAGE_NAME + "\"");
+ // via git
+ var index = txt.IndexOf("\"" + Settings.PACKAGE_NAME + "\": \"" + Settings.GITHUB + ".git");
if (index != -1)
{
- var end_index = txt.IndexOf(",", index);
- var old_str = txt.Substring(index, end_index - index);
+ var end_index = txt.IndexOf("\"", index + 1);
+ end_index = txt.IndexOf("\"", end_index + 1);
+ end_index = txt.IndexOf("\"", end_index + 1);
+ var old_str = txt.Substring(index, end_index - index + 1);
var new_str = string.Format("\"{0}\": \"{1}#{2}\"", Settings.PACKAGE_NAME, Settings.UPM_URL, latestVersion);
txt = txt.Replace(old_str, new_str);
File.WriteAllText(packagePath, txt);
AssetDatabase.Refresh();
return;
}
+
+ // via upm
+ index = txt.IndexOf("\"" + Settings.PACKAGE_NAME + "\": \"");
+ if (index != -1 && txt.IndexOf("openupm") != -1)
+ {
+ var end_index = txt.IndexOf("\"", index + 1);
+ end_index = txt.IndexOf("\"", end_index + 1);
+ end_index = txt.IndexOf("\"", end_index + 1);
+ var old_str = txt.Substring(index, end_index - index + 1);
+ var new_str = string.Format("\"{0}\": \"{1}\"", Settings.PACKAGE_NAME, latestVersion);
+ txt = txt.Replace(old_str, new_str);
+ File.WriteAllText(packagePath, txt);
+ AssetDatabase.Refresh();
+ return;
+ }
}
// via releases
- Application.OpenURL(Settings.GITHUB);
+ Application.OpenURL(Settings.GITHUB+"/releases");
}
private void DrawFixSettings()
@@ -145,7 +166,7 @@ private void DrawFixSettings()
#endif
EditorGUI.HelpBox(new Rect(10, 90, 580, 60), str, MessageType.Info);
GUI.enabled = false;
- GUI.Button(new Rect(440, 158, 150, 18), "Auto Fix");
+ GUI.Button(new Rect(440, 158, 150, 18), "All Fixed");
GUI.enabled = true;
return;
}
@@ -241,11 +262,13 @@ void BeginCheck()
EditorApplication.update += VersionCheckUpdate;
req.SendWebRequest();
}
+
private void VersionCheckUpdate()
{
if (req == null || req.isNetworkError || req.isHttpError)
{
EditorApplication.update -= VersionCheckUpdate;
+ latestVersion = "unknown";
return;
}
@@ -275,10 +298,10 @@ private void VersionCheckUpdate()
}
- public static class PlayerSettingsChecker
+ internal static class PlayerSettingsChecker
{
[InitializeOnLoadMethod]
- public static void OnInit()
+ internal static void OnInit()
{
bool isLinkTargetFixed;
bool isMemorySizeFixed;
@@ -321,7 +344,7 @@ internal static void GetSettingsFixed(out bool isRuntimeVersionFixed, out bool i
internal static class LOGO_BASE64
{
- public const string VALUE = "iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAMAAADUivDaAAAAq1BMVEUAAABKmtcvjtYzl" +
+ internal const string VALUE = "iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAMAAADUivDaAAAAq1BMVEUAAABKmtcvjtYzl" +
"9szmNszl9syl9k0mNs0mNwzmNs0mNszl9szl9s0mNs0mNwzmNw0mNwyltk0mNw0mNwzl9s0mNsymNs0mNszmNwzmNwzm" +
"NszmNs0mNwzl9w0mNwzmNw0mNs0mNs0mNwzl9wzmNs0mNwzmNs0mNwzl90zmNszmNszl9szmNsxmNszmNszmNw0mNwzm" +
"Nw0mNs2neM4pe41mt43ouo2oOY5qfM+UHlaAAAAMnRSTlMAAwXN3sgI+/069MSCK6M/MA74h9qfFHB8STWMJ9OSdmNcI" +
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index dc903c94..9746e023 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -7,7 +7,7 @@ public static class Settings
public const string QQ_GROUP_LINK = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
public const string EMAIL = "799329256@qq.com";
public const string AUHTOR = "psygame";
- public const string VERSION = "2.3.1";
+ public const string VERSION = "2.3.2";
public const string PACKAGE_NAME = "com.psygame.unitywebsocket";
public const string UPM_URL = "https://github.com/psygame/UnityWebSocket.git";
}
From e949db3b0fd9374aef0166be23a22a5da3375ce0 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Mon, 24 Aug 2020 13:46:43 +0800
Subject: [PATCH 33/66] fix v2.3.2
---
Scripts/Runtime/Core/Settings.cs | 2 +-
package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index 9746e023..bce475a7 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -1,6 +1,6 @@
namespace UnityWebSocket
{
- public static class Settings
+ internal static class Settings
{
public const string GITHUB = "https://github.com/psygame/UnityWebSocket";
public const string QQ_GROUP = "1126457634";
diff --git a/package.json b/package.json
index 7ba34ebe..1d4bb4fc 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "com.psygame.unitywebsocket",
"displayName": "UnityWebSocket",
- "version": "2.3.1",
+ "version": "2.3.2",
"unity": "2018.3",
"description": "The Best Unity WebSocket Plugin for All Platforms.",
"keywords": [ "websocket", "webgl", "socket", "jslib" ],
From e33a2f3e9314458cf0304b27128e5db0b47e31e9 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Mon, 24 Aug 2020 13:47:29 +0800
Subject: [PATCH 34/66] fix public
---
Scripts/Runtime/Core/Settings.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index bce475a7..9746e023 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -1,6 +1,6 @@
namespace UnityWebSocket
{
- internal static class Settings
+ public static class Settings
{
public const string GITHUB = "https://github.com/psygame/UnityWebSocket";
public const string QQ_GROUP = "1126457634";
From cc0960ce795a244de529accbbe2b1c361b9a9277 Mon Sep 17 00:00:00 2001
From: yinlong <799329256@qq.com>
Date: Mon, 24 Aug 2020 13:49:57 +0800
Subject: [PATCH 35/66] remove demo.meta
---
Samples~/Demo.unity.meta | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 Samples~/Demo.unity.meta
diff --git a/Samples~/Demo.unity.meta b/Samples~/Demo.unity.meta
deleted file mode 100644
index 2a694d73..00000000
--- a/Samples~/Demo.unity.meta
+++ /dev/null
@@ -1,7 +0,0 @@
-fileFormatVersion: 2
-guid: b9e0f303577eab04b8c94ba1bfe99d69
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
From ef97e89387043f73461faf61409145b8fb7f960f Mon Sep 17 00:00:00 2001
From: psygame <799329256@qq.com>
Date: Thu, 3 Sep 2020 16:02:50 +0800
Subject: [PATCH 36/66] Update README.md
---
README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 33b5bb9e..d59001a8 100644
--- a/README.md
+++ b/README.md
@@ -14,13 +14,13 @@
## **快速开始**
-#### **安装环境**
+### **安装环境**
- Unity 2018.3 或更高。
- 无其他SDK依赖。
-#### **安装方法**
+### **安装方法**
- **通过 OpenUPM 安装**
@@ -50,7 +50,7 @@
在 [Releases](https://github.com/psygame/UnityWebSocket/releases) 页面中,下载对应版本的 `UnityWebSocket.unitypackage` 安装包,然后导入到您的项目中。
-#### **使用方法**
+### **使用方法**
- 代码示例
```csharp
@@ -82,7 +82,7 @@
-#### **注意(Warning)**
+### **注意(Warning)**
- 插件中多个命名空间中存在 **WebSocket** 类,适用不同环境,请根据自身需求选择。
@@ -93,5 +93,5 @@
UnityWebSocket.WebGL | WebGL平台 | 异步 | 仅支持WebGL平台下的通信。
UnityWebSocket.NoWebGL | 非WebGL平台 | 异步 | 仅支持非WebGL平台下的通信。
-#### **QQ 交流群**
+### **QQ 交流群**
- 1126457634 >>> [入群通道](https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd) <<<
From abd58a9011ab38d9ce9bb1a8b910c09939e50742 Mon Sep 17 00:00:00 2001
From: yinlong
Date: Thu, 3 Sep 2020 16:20:51 +0800
Subject: [PATCH 37/66] fix readme
---
README.md | 8 ++++----
README_EN.md | 14 +++++++-------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index d59001a8..09c8f039 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,8 @@
### **使用方法**
- 代码示例
-```csharp
+
+ ```csharp
// 命名空间
using UnityWebSocket;
@@ -70,8 +71,8 @@
string address = "ws://echo.websocket.org";
socket.ConnectAsync(address);
- // 发送数据(两种发送方式)
- socket.SendAsync(str); // 发送类型 String 类型数据
+ // 发送数据(两种方式)
+ socket.SendAsync(str); // 发送 string 类型数据
socket.SendAsync(bytes); // 发送 byte[] 类型数据
// 关闭连接
@@ -81,7 +82,6 @@
- 详细使用方法可参考项目中的 [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) 示例代码。
-
### **注意(Warning)**
- 插件中多个命名空间中存在 **WebSocket** 类,适用不同环境,请根据自身需求选择。
diff --git a/README_EN.md b/README_EN.md
index 11fc94ff..f822efa5 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -14,12 +14,12 @@
## **Quick Start**
-#### **Requirements**
+### **Requirements**
- Unity 2018.3 or later
- No other SDK are required
-#### **Installation**
+### **Installation**
- **Using OpenUPM**
@@ -43,14 +43,13 @@
To update the package, change suffix `#{version}` to the target version.
* e.g. `"com.psygame.unitywebsocket": "https://github.com/psygame/UnityWebSocket.git#2.3.0",`
-
- **Using Unity Package**
Download an `UnityWebSocket.unitypackage` file from [Releases](https://github.com/psygame/UnityWebSocket/releases) page.
Import it into your Unity project.
-#### **Usage**
+### **Usage**
- Easy to use
@@ -71,8 +70,8 @@
string address = "ws://echo.websocket.org";
socket.ConnectAsync(address);
- // send data (tow ways)
- socket.SendAsync(str); // send String data
+ // send data (two ways)
+ socket.SendAsync(str); // send string data
socket.SendAsync(bytes); // send byte[] data
// close connection
@@ -81,7 +80,8 @@
- more detail usage, see the [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) code in project。
-#### **Attention(Warning)**
+
+### **Attention(Warning)**
- there are many **WebSocket** class in different namespace, use in different situations.
From d3f122ca5f23916c6b6da1690c13d7b7752f9ca2 Mon Sep 17 00:00:00 2001
From: yinlong
Date: Fri, 4 Sep 2020 13:44:36 +0800
Subject: [PATCH 38/66] fix editor window color
---
Scripts/Editor/SettingsWindow.cs | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 20dec66b..3e39f2be 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -32,6 +32,10 @@ private void OnGUI()
DrawSeparator(186);
DrawHelper();
DrawFooter();
+
+ //TODO: Suggest Package Installation
+ //TODO: WebGL.memorySize Custom
+ //TODO: Environment Check
}
private void DrawLogo()
@@ -51,11 +55,11 @@ private void DrawSeparator(int y)
EditorGUI.DrawRect(new Rect(10, y, 580, 1), Color.white * 0.5f);
}
- private GUIStyle TextStyle(int fontSize = 10, TextAnchor alignment = TextAnchor.UpperLeft)
+ private GUIStyle TextStyle(int fontSize = 10, TextAnchor alignment = TextAnchor.UpperLeft, float alpha = 0.85f)
{
var style = new GUIStyle();
style.fontSize = fontSize;
- style.normal.textColor = Color.white * 0.85f;
+ style.normal.textColor = (EditorGUIUtility.isProSkin ? Color.white : Color.black) * alpha;
style.alignment = alignment;
style.richText = true;
return style;
@@ -144,7 +148,7 @@ private void UpdateVersion()
}
// via releases
- Application.OpenURL(Settings.GITHUB+"/releases");
+ Application.OpenURL(Settings.GITHUB + "/releases");
}
private void DrawFixSettings()
@@ -248,8 +252,9 @@ private void DrawHelper()
private void DrawFooter()
{
- GUI.Label(new Rect(10, 230, 400, 10), "Developed by " + Settings.AUHTOR, TextStyle(alignment: TextAnchor.MiddleCenter));
- GUI.Label(new Rect(10, 250, 400, 10), "All rights reserved", TextStyle(alignment: TextAnchor.MiddleCenter));
+ var style = TextStyle(10, TextAnchor.MiddleCenter);
+ GUI.Label(new Rect(10, 230, 360, 10), "Developed by " + Settings.AUHTOR, style);
+ GUI.Label(new Rect(10, 250, 360, 10), "All rights reserved", style);
}
UnityWebRequest req;
From 56a2e6af8b9a68c41bfff1d522d4386df4fae371 Mon Sep 17 00:00:00 2001
From: yinlong
Date: Thu, 17 Sep 2020 16:25:35 +0800
Subject: [PATCH 39/66] v2.3.3, optimize editor
---
README.md | 6 +--
README_EN.md | 6 +--
Scripts/Editor/SettingsWindow.cs | 81 ++++++++++++++++++++++++--------
Scripts/Runtime/Core/Settings.cs | 2 +-
package.json | 9 +++-
5 files changed, 76 insertions(+), 28 deletions(-)
diff --git a/README.md b/README.md
index 09c8f039..1f6d45e0 100644
--- a/README.md
+++ b/README.md
@@ -59,7 +59,8 @@
using UnityWebSocket;
// 创建实例
- WebSocket scoket = new WebSocket();
+ string address = "ws://echo.websocket.org";
+ WebSocket scoket = new WebSocket(address);
// 注册回调
scoket.OnOpen += OnOpen;
@@ -68,8 +69,7 @@
socket.OnError += OnError;
// 连接
- string address = "ws://echo.websocket.org";
- socket.ConnectAsync(address);
+ socket.ConnectAsync();
// 发送数据(两种方式)
socket.SendAsync(str); // 发送 string 类型数据
diff --git a/README_EN.md b/README_EN.md
index f822efa5..bd9a668a 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -58,7 +58,8 @@
using UnityWebSocket;
// create instance
- WebSocket scoket = new WebSocket();
+ string address = "ws://echo.websocket.org";
+ WebSocket scoket = new WebSocket(address);
// register callback
scoket.OnOpen += OnOpen;
@@ -67,8 +68,7 @@
socket.OnError += OnError;
// connect
- string address = "ws://echo.websocket.org";
- socket.ConnectAsync(address);
+ socket.ConnectAsync();
// send data (two ways)
socket.SendAsync(str); // send string data
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 3e39f2be..35b820a6 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -8,6 +8,8 @@ namespace UnityWebSocket.Editor
{
internal class SettingsWindow : EditorWindow
{
+ internal static readonly int[] ASM_MEMORY_SIZE = new int[] { 256, 512, 1024 };
+ internal static readonly int[] LINKER_TARGET = new int[] { 0, 2 };
static SettingsWindow window = null;
[MenuItem("Tools/UnityWebSocket", priority = 1)]
internal static void Open()
@@ -29,12 +31,12 @@ private void OnGUI()
DrawVersion();
DrawSeparator(80);
DrawFixSettings();
+ DrawMemorySelector();
+ DrawLinkerTargetSelector();
DrawSeparator(186);
DrawHelper();
DrawFooter();
-
//TODO: Suggest Package Installation
- //TODO: WebGL.memorySize Custom
//TODO: Environment Check
}
@@ -151,6 +153,42 @@ private void UpdateVersion()
Application.OpenURL(Settings.GITHUB + "/releases");
}
+ private void DrawMemorySelector()
+ {
+ var ms_index = -1;
+ var memoryArrayStr = new string[ASM_MEMORY_SIZE.Length];
+ for (int i = 0; i < ASM_MEMORY_SIZE.Length; i++)
+ {
+ if (ASM_MEMORY_SIZE[i] == PlayerSettings.WebGL.memorySize)
+ ms_index = i;
+ memoryArrayStr[i] = ASM_MEMORY_SIZE[i].ToString();
+ }
+ GUI.Label(new Rect(10, 160, 80, 18), "Memory Size: ", TextStyle());
+ ms_index = EditorGUI.Popup(new Rect(100, 160, 70, 18), ms_index, memoryArrayStr);
+ if (ms_index >= 0 && ASM_MEMORY_SIZE[ms_index] != PlayerSettings.WebGL.memorySize)
+ {
+ PlayerSettings.WebGL.memorySize = ASM_MEMORY_SIZE[ms_index];
+ }
+ }
+
+ private void DrawLinkerTargetSelector()
+ {
+ var _index = -1;
+ var lstStr = new string[LINKER_TARGET.Length];
+ for (int i = 0; i < LINKER_TARGET.Length; i++)
+ {
+ if (LINKER_TARGET[i] == (int)PlayerSettings.WebGL.linkerTarget)
+ _index = i;
+ lstStr[i] = ((WebGLLinkerTarget)LINKER_TARGET[i]).ToString();
+ }
+ GUI.Label(new Rect(220, 160, 80, 18), "Linker Target: ", TextStyle());
+ _index = EditorGUI.Popup(new Rect(310, 160, 70, 18), _index, lstStr);
+ if (_index >= 0 && LINKER_TARGET[_index] != (int)PlayerSettings.WebGL.linkerTarget)
+ {
+ PlayerSettings.WebGL.linkerTarget = (WebGLLinkerTarget)LINKER_TARGET[_index];
+ }
+ }
+
private void DrawFixSettings()
{
bool isRuntimeVersionFixed;
@@ -162,13 +200,13 @@ private void DrawFixSettings()
if (isAllFixed)
{
var str = "All Settings Fixed:";
- str += "\n√ PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;";
+ str += "\n√ PlayerSettings.WebGL.linkerTarget = " + PlayerSettings.WebGL.linkerTarget + ";";
str += "\n√ PlayerSettings.WebGL.memorySize = " + PlayerSettings.WebGL.memorySize + ";";
str += "\n√ PlayerSettings.WebGL.decompressionFallback = true;";
#if !UNITY_2019_3_OR_NEWER
str += "\n√ PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest;";
#endif
- EditorGUI.HelpBox(new Rect(10, 90, 580, 60), str, MessageType.Info);
+ EditorGUI.HelpBox(new Rect(10, 90, 580, 62), str, MessageType.Info);
GUI.enabled = false;
GUI.Button(new Rect(440, 158, 150, 18), "All Fixed");
GUI.enabled = true;
@@ -177,9 +215,9 @@ private void DrawFixSettings()
var fixStr = "In order to run UnityWebSocket normally, we must fix some SETTINGS below:";
if (isLinkTargetFixed)
- fixStr += "\n√ PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;";
+ fixStr += "\n√ PlayerSettings.WebGL.linkerTarget = " + PlayerSettings.WebGL.linkerTarget + ";";
else
- fixStr += "\n× PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;";
+ fixStr += "\n× PlayerSettings.WebGL.linkerTarget = [Appropriate Value];";
if (isMemorySizeFixed)
fixStr += "\n√ PlayerSettings.WebGL.memorySize = " + PlayerSettings.WebGL.memorySize + ";";
@@ -189,16 +227,16 @@ private void DrawFixSettings()
if (isDecompressionFallbackFixed)
fixStr += "\n√ PlayerSettings.WebGL.decompressionFallback = true;";
else
- fixStr += "\n× PlayerSettings.WebGL.decompressionFallback = true;";
+ fixStr += "\n× PlayerSettings.WebGL.decompressionFallback = false;";
#if !UNITY_2019_3_OR_NEWER
if (isRuntimeVersionFixed)
fixStr += "\n√ PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest;";
else
- fixStr += "\n× PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest; (Need Manual Fix)";
+ fixStr += "\n× PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Legacy; (Need Manual Fix)";
#endif
- EditorGUI.HelpBox(new Rect(10, 90, 580, 60), fixStr, MessageType.Warning);
+ EditorGUI.HelpBox(new Rect(10, 90, 580, 62), fixStr, MessageType.Warning);
if (GUI.Button(new Rect(440, 158, 150, 18), "Auto Fix"))
{
@@ -207,10 +245,8 @@ private void DrawFixSettings()
PlayerSettings.WebGL.linkerTarget = (WebGLLinkerTarget)2;
#endif
-#if UNITY_2019_1_OR_NEWER
if (!isMemorySizeFixed)
- PlayerSettings.WebGL.memorySize = 128;
-#endif
+ PlayerSettings.WebGL.memorySize = ASM_MEMORY_SIZE[0];
#if UNITY_2020_1_OR_NEWER
if (!isDecompressionFallbackFixed)
@@ -252,9 +288,8 @@ private void DrawHelper()
private void DrawFooter()
{
- var style = TextStyle(10, TextAnchor.MiddleCenter);
- GUI.Label(new Rect(10, 230, 360, 10), "Developed by " + Settings.AUHTOR, style);
- GUI.Label(new Rect(10, 250, 360, 10), "All rights reserved", style);
+ EditorGUI.DropShadowLabel(new Rect(10, 230, 400, 10), "Developed by " + Settings.AUHTOR, TextStyle(10, TextAnchor.MiddleCenter));
+ EditorGUI.DropShadowLabel(new Rect(10, 250, 400, 10), "All rights reserved", TextStyle(10, TextAnchor.MiddleCenter));
}
UnityWebRequest req;
@@ -321,6 +356,16 @@ internal static void OnInit()
}
}
+ internal static bool _IsInArray(int[] array, int val)
+ {
+ for (int i = 0; i < array.Length; i++)
+ {
+ if (val == array[i])
+ return true;
+ }
+ return false;
+ }
+
internal static void GetSettingsFixed(out bool isRuntimeVersionFixed, out bool isLinkTargetFixed, out bool isMemorySizeFixed, out bool isDecompressionFallbackFixed)
{
isRuntimeVersionFixed = true;
@@ -329,16 +374,14 @@ internal static void GetSettingsFixed(out bool isRuntimeVersionFixed, out bool i
isDecompressionFallbackFixed = true;
#if UNITY_2018_1_OR_NEWER
- isLinkTargetFixed = PlayerSettings.WebGL.linkerTarget == (WebGLLinkerTarget)2;
+ isLinkTargetFixed = _IsInArray(SettingsWindow.LINKER_TARGET, (int)PlayerSettings.WebGL.linkerTarget);
#endif
#if !UNITY_2019_3_OR_NEWER
isRuntimeVersionFixed = PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest;
#endif
-#if UNITY_2019_1_OR_NEWER
- isMemorySizeFixed = PlayerSettings.WebGL.memorySize >= 16;
-#endif
+ isMemorySizeFixed = _IsInArray(SettingsWindow.ASM_MEMORY_SIZE, PlayerSettings.WebGL.memorySize);
#if UNITY_2020_1_OR_NEWER
isDecompressionFallbackFixed = PlayerSettings.WebGL.decompressionFallback;
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index 9746e023..1b088321 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -7,7 +7,7 @@ public static class Settings
public const string QQ_GROUP_LINK = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
public const string EMAIL = "799329256@qq.com";
public const string AUHTOR = "psygame";
- public const string VERSION = "2.3.2";
+ public const string VERSION = "2.3.3";
public const string PACKAGE_NAME = "com.psygame.unitywebsocket";
public const string UPM_URL = "https://github.com/psygame/UnityWebSocket.git";
}
diff --git a/package.json b/package.json
index 1d4bb4fc..e1b45193 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,15 @@
{
"name": "com.psygame.unitywebsocket",
"displayName": "UnityWebSocket",
- "version": "2.3.2",
+ "version": "2.3.3",
"unity": "2018.3",
"description": "The Best Unity WebSocket Plugin for All Platforms.",
- "keywords": [ "websocket", "webgl", "socket", "jslib" ],
+ "keywords": [
+ "websocket",
+ "webgl",
+ "socket",
+ "jslib"
+ ],
"category": "network",
"dependencies": {},
"license": "MIT",
From 1d4b8fb26a8efbc17a69731e1933bc82e8dce13b Mon Sep 17 00:00:00 2001
From: yinlong
Date: Thu, 17 Sep 2020 16:36:55 +0800
Subject: [PATCH 40/66] fix footer
---
Scripts/Editor/SettingsWindow.cs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Scripts/Editor/SettingsWindow.cs b/Scripts/Editor/SettingsWindow.cs
index 35b820a6..57d05d3b 100644
--- a/Scripts/Editor/SettingsWindow.cs
+++ b/Scripts/Editor/SettingsWindow.cs
@@ -36,6 +36,7 @@ private void OnGUI()
DrawSeparator(186);
DrawHelper();
DrawFooter();
+
//TODO: Suggest Package Installation
//TODO: Environment Check
}
@@ -288,8 +289,8 @@ private void DrawHelper()
private void DrawFooter()
{
- EditorGUI.DropShadowLabel(new Rect(10, 230, 400, 10), "Developed by " + Settings.AUHTOR, TextStyle(10, TextAnchor.MiddleCenter));
- EditorGUI.DropShadowLabel(new Rect(10, 250, 400, 10), "All rights reserved", TextStyle(10, TextAnchor.MiddleCenter));
+ EditorGUI.DropShadowLabel(new Rect(10, 230, 400, 20), "Developed by " + Settings.AUHTOR);
+ EditorGUI.DropShadowLabel(new Rect(10, 250, 400, 20), "All rights reserved");
}
UnityWebRequest req;
From a42e6003cb03f914ee98faf5f4fb020a1a1f5cdb Mon Sep 17 00:00:00 2001
From: yinlong
Date: Fri, 18 Sep 2020 14:19:53 +0800
Subject: [PATCH 41/66] =?UTF-8?q?v2.4.0=20-=20=E4=BF=AE=E6=94=B9=20SendAsy?=
=?UTF-8?q?nc=20=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=AE=8C?=
=?UTF-8?q?=E6=88=90=E5=9B=9E=E8=B0=83=20-=20=E4=BF=AE=E6=94=B9=E9=9D=9EWe?=
=?UTF-8?q?bGL=E5=B9=B3=E5=8F=B0=E4=B8=8B=20WebSocket=20=E8=BF=9E=E6=8E=A5?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8=E4=B8=BB=E7=BA=BF=E7=A8=8B=E4=B8=8A?=
=?UTF-8?q?=E5=BC=82=E6=AD=A5=E6=93=8D=E4=BD=9C=20-=20=E6=95=B4=E7=90=86?=
=?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B7=AF=E5=BE=84=EF=BC=8C=E5=88=A0=E9=99=A4?=
=?UTF-8?q?Tests=E6=96=87=E4=BB=B6=E5=A4=B9=EF=BC=8C=E6=95=B4=E5=90=88?=
=?UTF-8?q?=E8=87=B3Demo=E4=B8=8B=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
README_EN.md | 2 +-
Tests.meta => Samples~/Demo.meta | 4 +-
.../Demo/Demo.unity.meta | 4 +-
.../Demo/UnityWebSocketDemo.cs | 51 ++---
.../Demo/UnityWebSocketDemo.cs.meta | 0
Scripts/Runtime/Core/IWebSocket.cs | 26 +--
Scripts/Runtime/Core/Settings.cs | 2 +-
.../Implementation/NoWebGL/WebSocket.cs | 211 +++++++++---------
.../Implementation/Synchronized/WebSocket.cs | 48 +---
.../Implementation/Uniform/WebSocket.cs | 8 +-
.../Runtime/Implementation/WebGL/WebSocket.cs | 8 +-
Tests/UnityWebSocket.Test.asmdef | 14 --
package.json | 2 +-
14 files changed, 157 insertions(+), 225 deletions(-)
rename Tests.meta => Samples~/Demo.meta (62%)
rename Tests/UnityWebSocket.Test.asmdef.meta => Samples~/Demo/Demo.unity.meta (59%)
rename Tests/UnityWebSocketTest.cs => Samples~/Demo/UnityWebSocketDemo.cs (85%)
rename Tests/UnityWebSocketTest.cs.meta => Samples~/Demo/UnityWebSocketDemo.cs.meta (100%)
delete mode 100644 Tests/UnityWebSocket.Test.asmdef
diff --git a/README.md b/README.md
index 1f6d45e0..afc4d4a6 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@
socket.CloseAsync();
```
-- 详细使用方法可参考项目中的 [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) 示例代码。
+- 详细使用方法可参考项目中的 [UnityWebSocketDemo.cs](Samples~/Demo/UnityWebSocketDemo.cs) 示例代码。
### **注意(Warning)**
diff --git a/README_EN.md b/README_EN.md
index bd9a668a..6dee4854 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -78,7 +78,7 @@
socket.CloseAsync();
```
-- more detail usage, see the [UnityWebSocketTest.cs](Tests/UnityWebSocketTest.cs) code in project。
+- more detail usage, see the [UnityWebSocketDemo.cs](Samples~/Demo/UnityWebSocketDemo.cs) code in project。
### **Attention(Warning)**
diff --git a/Tests.meta b/Samples~/Demo.meta
similarity index 62%
rename from Tests.meta
rename to Samples~/Demo.meta
index 5b38e38e..ea78ec31 100644
--- a/Tests.meta
+++ b/Samples~/Demo.meta
@@ -1,8 +1,6 @@
fileFormatVersion: 2
-guid: 1b26d420fd41d1643b77c70b1fcc075f
+guid: aab4c0dd88d44cd4e817c3f1994407b4
folderAsset: yes
-timeCreated: 1530672580
-licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
diff --git a/Tests/UnityWebSocket.Test.asmdef.meta b/Samples~/Demo/Demo.unity.meta
similarity index 59%
rename from Tests/UnityWebSocket.Test.asmdef.meta
rename to Samples~/Demo/Demo.unity.meta
index 18d62857..772fdf86 100644
--- a/Tests/UnityWebSocket.Test.asmdef.meta
+++ b/Samples~/Demo/Demo.unity.meta
@@ -1,6 +1,6 @@
fileFormatVersion: 2
-guid: cddcf2ec2291b416eb85e8fdb077ce0d
-AssemblyDefinitionImporter:
+guid: 65671216fb4e42d4f89ed6eeca36060d
+DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
diff --git a/Tests/UnityWebSocketTest.cs b/Samples~/Demo/UnityWebSocketDemo.cs
similarity index 85%
rename from Tests/UnityWebSocketTest.cs
rename to Samples~/Demo/UnityWebSocketDemo.cs
index 17d0c5c2..db6ba9a2 100644
--- a/Tests/UnityWebSocketTest.cs
+++ b/Samples~/Demo/UnityWebSocketDemo.cs
@@ -1,7 +1,7 @@
using UnityEngine;
using UnityWebSocket;
-public class UnityWebSocketTest : MonoBehaviour
+public class UnityWebSocketDemo : MonoBehaviour
{
public string url = "ws://echo.websocket.org";
private IWebSocket socket;
@@ -59,12 +59,10 @@ private void OnGUI()
{
if (!string.IsNullOrEmpty(sendText))
{
- socket.SendAsync(sendText, () =>
- {
- if (logMessage)
- AddLog(string.Format("Send: {0}\n", sendText));
- sendCount += 1;
- });
+ socket.SendAsync(sendText);
+ if (logMessage)
+ AddLog(string.Format("Send: {0}\n", sendText));
+ sendCount += 1;
}
}
if (GUILayout.Button("Send Bytes"))
@@ -72,12 +70,11 @@ private void OnGUI()
if (!string.IsNullOrEmpty(sendText))
{
var bytes = System.Text.Encoding.UTF8.GetBytes(sendText);
- socket.SendAsync(bytes, () =>
- {
- if (logMessage)
- AddLog(string.Format("Send Bytes ({1}): {0}\n", sendText, bytes.Length));
- sendCount += 1;
- });
+ socket.SendAsync(bytes);
+
+ if (logMessage)
+ AddLog(string.Format("Send Bytes ({1}): {0}\n", sendText, bytes.Length));
+ sendCount += 1;
}
}
if (GUILayout.Button("Send x100"))
@@ -87,12 +84,11 @@ private void OnGUI()
for (int i = 0; i < 100; i++)
{
var text = (i + 1).ToString() + ". " + sendText;
- socket.SendAsync(text, () =>
- {
- if (logMessage)
- AddLog(string.Format("Send: {0}\n", text));
- sendCount += 1;
- });
+ socket.SendAsync(text);
+
+ if (logMessage)
+ AddLog(string.Format("Send: {0}\n", text));
+ sendCount += 1;
}
}
}
@@ -104,12 +100,10 @@ private void OnGUI()
{
var text = (i + 1).ToString() + ". " + sendText;
var bytes = System.Text.Encoding.UTF8.GetBytes(text);
- socket.SendAsync(bytes, () =>
- {
- if (logMessage)
- AddLog(string.Format("Send Bytes ({1}): {0}\n", text, bytes.Length));
- sendCount += 1;
- });
+ socket.SendAsync(bytes);
+ if (logMessage)
+ AddLog(string.Format("Send Bytes ({1}): {0}\n", text, bytes.Length));
+ sendCount += 1;
}
}
}
@@ -174,4 +168,11 @@ private void Socket_OnError(object sender, ErrorEventArgs e)
AddLog(string.Format("Error: {0}\n", e.Message));
}
+ private void OnApplicationQuit()
+ {
+ if (socket != null && socket.ReadyState != WebSocketState.Closed)
+ {
+ socket.CloseAsync();
+ }
+ }
}
\ No newline at end of file
diff --git a/Tests/UnityWebSocketTest.cs.meta b/Samples~/Demo/UnityWebSocketDemo.cs.meta
similarity index 100%
rename from Tests/UnityWebSocketTest.cs.meta
rename to Samples~/Demo/UnityWebSocketDemo.cs.meta
diff --git a/Scripts/Runtime/Core/IWebSocket.cs b/Scripts/Runtime/Core/IWebSocket.cs
index 5e14219d..37c57ebf 100644
--- a/Scripts/Runtime/Core/IWebSocket.cs
+++ b/Scripts/Runtime/Core/IWebSocket.cs
@@ -6,7 +6,7 @@ namespace UnityWebSocket
/// IWebSocket indicate a network connection.
/// It can be connecting, connected, closing or closed state.
/// You can send and receive messages by using it.
- /// Register onreceive callback for handling received messages.
+ /// Register callbacks for handling messages.
/// -----------------------------------------------------------
/// IWebSocket 表示一个网络连接,
/// 它可以是 connecting connected closing closed 状态,
@@ -69,22 +69,13 @@ public interface IWebSocket
///
/// An array of that represents the binary data to send.
///
- ///
- ///
- /// An Action delegate or
- /// if not needed.
- ///
- ///
- /// The delegate invokes the method called when the send is complete.
- ///
- ///
///
/// The current state of the connection is not Open.
///
///
/// is .
///
- void SendAsync(byte[] data, Action completed = null);
+ void SendAsync(byte[] data);
///
/// Sends the specified data using the WebSocket connection.
@@ -92,15 +83,6 @@ public interface IWebSocket
///
/// A that represents the text data to send.
///
- ///
- ///
- /// An Action delegate or
- /// if not needed.
- ///
- ///
- /// The delegate invokes the method called when the send is complete.
- ///
- ///
///
/// The current state of the connection is not Open.
///
@@ -108,9 +90,9 @@ public interface IWebSocket
/// is .
///
///
- /// could be UTF-8 encoded.
+ /// could not be UTF-8 encoded.
///
- void SendAsync(string text, Action completed = null);
+ void SendAsync(string text);
///
/// get the address which to connect.
diff --git a/Scripts/Runtime/Core/Settings.cs b/Scripts/Runtime/Core/Settings.cs
index 1b088321..2c414d48 100644
--- a/Scripts/Runtime/Core/Settings.cs
+++ b/Scripts/Runtime/Core/Settings.cs
@@ -7,7 +7,7 @@ public static class Settings
public const string QQ_GROUP_LINK = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd";
public const string EMAIL = "799329256@qq.com";
public const string AUHTOR = "psygame";
- public const string VERSION = "2.3.3";
+ public const string VERSION = "2.4.0";
public const string PACKAGE_NAME = "com.psygame.unitywebsocket";
public const string UPM_URL = "https://github.com/psygame/UnityWebSocket.git";
}
diff --git a/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs b/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs
index 67528e7f..e30e54e0 100644
--- a/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs
+++ b/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs
@@ -6,7 +6,6 @@
using System.Threading.Tasks;
using System.Net.WebSockets;
-
namespace UnityWebSocket.NoWebGL
{
public class WebSocket : IWebSocket
@@ -44,9 +43,16 @@ public WebSocketState ReadyState
private ClientWebSocket socket;
private CancellationTokenSource cts;
private bool IsCtsCancel { get { return cts == null || cts.IsCancellationRequested; } }
- private bool isSendThreadRunning;
- private bool isReceiveThreadRunning;
+ private bool isSendAsyncRunning;
+ private bool isReceiveAsyncRunning;
+
+ //TODO: OPTIMIZE THIS API
+ ///
+ /// run the socket async method on main thread, if you want.
+ ///
+ public static bool runOnMainThread { get; private set; } = false;
+ #region APIs
public WebSocket(string address)
{
this.Address = address;
@@ -61,30 +67,74 @@ public void ConnectAsync()
}
cts = new CancellationTokenSource();
socket = new ClientWebSocket();
- Task.Run(ConnectThread);
+ RunConnectAsync();
}
public void CloseAsync()
{
- Task.Run(CloseThread);
+ RunCloseAsync();
}
- public void SendAsync(byte[] data, Action completed = null)
+ public void SendAsync(byte[] data)
{
- var sendBuffer = SpawnBuffer(WebSocketMessageType.Binary, data, completed);
+ var sendBuffer = SpawnBuffer(WebSocketMessageType.Binary, data);
PushBuffer(sendBuffer);
}
- public void SendAsync(string text, Action completed = null)
+ public void SendAsync(string text)
{
var data = Encoding.UTF8.GetBytes(text);
- var sendBuffer = SpawnBuffer(WebSocketMessageType.Text, data, completed);
+ var sendBuffer = SpawnBuffer(WebSocketMessageType.Text, data);
PushBuffer(sendBuffer);
}
+ #endregion
+
+ #region Run Async
+ private async void RunConnectAsync()
+ {
+ Log("Run ConnectAsync ...");
+ if (runOnMainThread)
+ await _ConnectAsync();
+ else
+ await Task.Run(_ConnectAsync);
+ Log("Run ConnectAsync End !");
+ }
- private async Task ConnectThread()
+ private async void RunCloseAsync()
{
- // UnityEngine.Debug.Log("Connect Thread Start ...");
+ Log("Run CloseAsync ...");
+ if (runOnMainThread)
+ await _CloseAsync();
+ else
+ await Task.Run(_CloseAsync);
+ Log("Run CloseAsync End !");
+ }
+
+ private async void RunSendAsync()
+ {
+ Log("Run SendAsync ...");
+ if (runOnMainThread)
+ await _SendAsync();
+ else
+ await Task.Run(_SendAsync);
+ Log("Run SendAsync End !");
+ }
+
+ private async void RunReceiveAsync()
+ {
+ Log("Run ReceiveAsync ...");
+ if (runOnMainThread)
+ await _ReceiveAsync();
+ else
+ await Task.Run(_ReceiveAsync);
+ Log("Run ReceiveAsync End !");
+ }
+
+ #endregion
+
+ private async Task _ConnectAsync()
+ {
+ Log("ConnectAsync Begin ...");
try
{
@@ -99,48 +149,37 @@ private async Task ConnectThread()
return;
}
- LongRunningTask(SendThread);
- LongRunningTask(ReceiveThread);
+ RunSendAsync();
+ RunReceiveAsync();
HandleOpen();
- // UnityEngine.Debug.Log("Connect Thread Stop !");
+ Log("ConnectAsync End !");
}
- private async void CloseThread()
+ private async Task _CloseAsync()
{
- // UnityEngine.Debug.Log("Close Thread Start ...");
+ Log("CloseAsync Begin ...");
try
{
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Normal Closure", cts.Token);
}
- catch { }
-
- // UnityEngine.Debug.Log("Close Thread Stop !");
- }
-
- private async void DisposeThread()
- {
- // UnityEngine.Debug.Log("Dispose Thread Start ...");
-
- while (!IsCtsCancel || isSendThreadRunning || isReceiveThreadRunning)
+ catch (Exception e)
{
- await Task.Delay(1);
+ HandleError(e);
}
- SocketDispose();
-
- // UnityEngine.Debug.Log("Dispose Thread Stop !");
+ Log("CloseAsync End !");
}
- private async Task SendThread()
+ private async Task _SendAsync()
{
- // UnityEngine.Debug.Log("Send Thread Start ...");
+ Log("SendAsync Begin ...");
try
{
- isSendThreadRunning = true;
+ isSendAsyncRunning = true;
SendBuffer buffer = null;
while (!IsCtsCancel)
{
@@ -153,11 +192,10 @@ private async Task SendThread()
if (!IsCtsCancel)
{
await socket.SendAsync(buffer.buffer, buffer.type, true, cts.Token);
- HandleSent(buffer.callback);
}
ReleaseBuffer(buffer);
- // UnityEngine.Debug.Log("SendBuffers: " + sendBuffers.Count + ", PoolelBuffers: " + pooledSendBuffers.Count);
+ Log("SendBuffers: " + sendBuffers.Count + ", PoolelBuffers: " + pooledSendBuffers.Count);
}
}
catch (Exception e)
@@ -166,19 +204,19 @@ private async Task SendThread()
}
finally
{
- isSendThreadRunning = false;
while (sendBuffers.Count > 0)
{
ReleaseBuffer(PopBuffer());
}
+ isSendAsyncRunning = false;
}
- // UnityEngine.Debug.Log("Send Thread Stop !");
+ Log("SendAsync End !");
}
- private async Task ReceiveThread()
+ private async Task _ReceiveAsync()
{
- // UnityEngine.Debug.Log("Receive Thread Start ...");
+ Log("ReceiveAsync Begin ...");
var bufferCap = 1024;
var buffer = new byte[bufferCap];
@@ -190,7 +228,7 @@ private async Task ReceiveThread()
try
{
- isReceiveThreadRunning = true;
+ isReceiveAsyncRunning = true;
var segment = new ArraySegment(buffer);
while (!IsCtsCancel && !isClosed)
@@ -205,7 +243,7 @@ private async Task ReceiveThread()
Array.Copy(buffer, newBuffer, buffer.Length);
buffer = newBuffer;
newBuffer = null;
- // UnityEngine.Debug.Log("Expand Receive Buffer to " + bufferCap);
+ Log("Expand Receive Buffer to " + bufferCap);
}
if (!result.EndOfMessage)
@@ -246,20 +284,24 @@ private async Task ReceiveThread()
}
finally
{
- isReceiveThreadRunning = false;
- buffer = null;
+ isReceiveAsyncRunning = false;
}
cts.Cancel();
- await Task.Run(DisposeThread);
- HandleClose(closeCode, closeReason);
- // UnityEngine.Debug.Log("Receive Thread Stop !");
- }
+ Log("Wait For Close ...");
- private void LongRunningTask(Func function)
- {
- Task.Factory.StartNew(function, cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
+ while (!IsCtsCancel || isSendAsyncRunning || isReceiveAsyncRunning)
+ {
+ await Task.Delay(1);
+ }
+
+ Log("Wait For Close End !");
+
+ HandleClose(closeCode, closeReason);
+ SocketDispose();
+
+ Log("Receive Async End !");
}
private void SocketDispose()
@@ -270,6 +312,7 @@ private void SocketDispose()
socket = null;
}
+ //TODO: OPTIMIZE Send Pool
private readonly Queue sendBuffers = new Queue