From a42e6003cb03f914ee98faf5f4fb020a1a1f5cdb Mon Sep 17 00:00:00 2001 From: yinlong Date: Fri, 18 Sep 2020 14:19:53 +0800 Subject: [PATCH] =?UTF-8?q?v2.4.0=20-=20=E4=BF=AE=E6=94=B9=20SendAsync=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=20-=20=E4=BF=AE=E6=94=B9=E9=9D=9EWebGL?= =?UTF-8?q?=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 1f6d45e..afc4d4a 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 bd9a668..6dee485 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 5b38e38..ea78ec3 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 18d6285..772fdf8 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 17d0c5c..db6ba9a 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 5e14219..37c57eb 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 1b08832..2c414d4 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 67528e7..e30e54e 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(); private readonly Queue pooledSendBuffers = new Queue(); @@ -277,7 +320,6 @@ class SendBuffer { public WebSocketMessageType type; public ArraySegment buffer; - public Action callback; } private void PushBuffer(SendBuffer sendBuffer) @@ -301,14 +343,13 @@ private SendBuffer PopBuffer() 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) + private SendBuffer SpawnBuffer(WebSocketMessageType type, byte[] bytes) { SendBuffer sendBuffer = null; if (pooledSendBuffers.Count <= 0) @@ -317,7 +358,6 @@ private SendBuffer SpawnBuffer(WebSocketMessageType type, byte[] bytes, Action c { type = WebSocketMessageType.Text, buffer = new ArraySegment(bytes), - callback = callback }; return sendBuffer; } @@ -329,73 +369,42 @@ private SendBuffer SpawnBuffer(WebSocketMessageType type, byte[] bytes, Action c 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); - } + Log("OnOpen"); + OnOpen?.Invoke(this, new OpenEventArgs()); } 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); - } + Log("OnMessage: " + opcode + "(" + rawData.Length + ")"); + OnMessage?.Invoke(this, new MessageEventArgs(opcode, rawData)); } 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); - } + Log("OnClose: " + reason + "(" + code + ")"); + OnClose?.Invoke(this, new CloseEventArgs(code, reason)); } private void HandleError(Exception exception) { - // UnityEngine.Debug.Log("OnError: " + exception.Message); - + Log("OnError: " + exception.Message); OnError?.Invoke(this, new ErrorEventArgs(exception.Message)); } + + [System.Diagnostics.Conditional("UNITY_EDITOR")] + private void Log(string msg) + { + UnityEngine.Debug.Log($"[UnityWebSocket]" + + $"[T-{Thread.CurrentThread.ManagedThreadId:D3}]" + + $"[{DateTime.Now.TimeOfDay}]" + + $" {msg}"); + } } } #endif diff --git a/Scripts/Runtime/Implementation/Synchronized/WebSocket.cs b/Scripts/Runtime/Implementation/Synchronized/WebSocket.cs index 5aa4fa2..65f4f08 100644 --- a/Scripts/Runtime/Implementation/Synchronized/WebSocket.cs +++ b/Scripts/Runtime/Implementation/Synchronized/WebSocket.cs @@ -38,40 +38,14 @@ public WebSocket(string address) WebSocketManager.Instance.Add(this); } - public void SendAsync(string data, Action completed = null) + public void SendAsync(string data) { - if (completed != null) - { - _socket.SendAsync(data, () => - { - lock (sendCallbackQueue) - { - sendCallbackQueue.Enqueue(completed); - } - }); - } - else - { - _socket.SendAsync(data); - } + _socket.SendAsync(data); } - public void SendAsync(byte[] data, Action completed = null) + public void SendAsync(byte[] data) { - if (completed != null) - { - _socket.SendAsync(data, () => - { - lock (sendCallbackQueue) - { - sendCallbackQueue.Enqueue(completed); - } - }); - } - else - { - _socket.SendAsync(data); - } + _socket.SendAsync(data); } public void ConnectAsync() @@ -85,22 +59,8 @@ public void 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; diff --git a/Scripts/Runtime/Implementation/Uniform/WebSocket.cs b/Scripts/Runtime/Implementation/Uniform/WebSocket.cs index 75ed966..50a6b44 100644 --- a/Scripts/Runtime/Implementation/Uniform/WebSocket.cs +++ b/Scripts/Runtime/Implementation/Uniform/WebSocket.cs @@ -49,14 +49,14 @@ public WebSocket(string address) } - public void SendAsync(string data, Action completed = null) + public void SendAsync(string data) { - _rawSocket.SendAsync(data, completed); + _rawSocket.SendAsync(data); } - public void SendAsync(byte[] data, Action completed = null) + public void SendAsync(byte[] data) { - _rawSocket.SendAsync(data, completed); + _rawSocket.SendAsync(data); } public void ConnectAsync() diff --git a/Scripts/Runtime/Implementation/WebGL/WebSocket.cs b/Scripts/Runtime/Implementation/WebGL/WebSocket.cs index 35473a9..2044922 100644 --- a/Scripts/Runtime/Implementation/WebGL/WebSocket.cs +++ b/Scripts/Runtime/Implementation/WebGL/WebSocket.cs @@ -69,22 +69,18 @@ public void CloseAsync() HandleOnError(WebSocketManager.GetErrorMessageFromCode(ret)); } - public void SendAsync(string text, Action completed = null) + public void SendAsync(string text) { 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) + public void SendAsync(byte[] data) { int ret = WebSocketManager.WebSocketSend(instanceID, data, data.Length); if (ret < 0) HandleOnError(WebSocketManager.GetErrorMessageFromCode(ret)); - if (completed != null) - completed.Invoke(); } } } diff --git a/Tests/UnityWebSocket.Test.asmdef b/Tests/UnityWebSocket.Test.asmdef deleted file mode 100644 index 28aadfb..0000000 --- a/Tests/UnityWebSocket.Test.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "UnityWebSocket.Test", - "references": [ - "UnityWebSocket.Runtime" - ], - "optionalUnityReferences": [], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [] -} \ No newline at end of file diff --git a/package.json b/package.json index e1b4519..dd6da66 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.psygame.unitywebsocket", "displayName": "UnityWebSocket", - "version": "2.3.3", + "version": "2.4.0", "unity": "2018.3", "description": "The Best Unity WebSocket Plugin for All Platforms.", "keywords": [