public void Close() { #if DOT_NET if (ClientWebSocket == null) { return; } ClientWebSocket.CloseAsync(WebSocketCloseStatus.Empty, null, CancellationToken.None); ClientWebSocket = null; #elif UNITY_WEBGL && !UNITY_EDITOR if (NativeWebSocket == null) { return; } webSocketInstances.Remove(NativeWebSocket.Id); NativeWebSocket.CloseAsync(); NativeWebSocket = null; #else if (WebSocket == null) { return; } WebSocket.CloseAsync(); WebSocket.OnOpen -= WebSocket_OnOpen; WebSocket.OnMessage -= WebSocket_OnMessage; WebSocket.OnError -= WebSocket_OnError; WebSocket.OnClose -= WebSocket_OnClose; WebSocket = null; #endif }
public void Close() { Debug.Log("[UnityWebSocket] Closing web socket connection."); #if UNITY_EDITOR || UNITY_STANDALONE if (WebSocket == null) { return; } WebSocket.CloseAsync(); WebSocket.OnOpen -= WebSocket_OnOpen; WebSocket.OnMessage -= WebSocket_OnMessage; WebSocket.OnError -= WebSocket_OnError; WebSocket.OnClose -= WebSocket_OnClose; WebSocket = null; #elif UNITY_WEBGL if (NativeWebSocket == null) { return; } NativeWebSocket.CloseAsync(); NativeWebSocket.SetOnOpen(null); NativeWebSocket.SetOnMessage(null); NativeWebSocket.SetOnError(null); NativeWebSocket.SetOnClose(null); NativeWebSocket = null; #endif }
public void Close() { #if DOT_NET #elif UNITY_WEBGL && !UNITY_EDITOR if (NativeWebSocket == null) { return; } webSocketInstances.Remove(NativeWebSocket.Id); NativeWebSocket.CloseAsync(); NativeWebSocket = null; #else if (WebSocket == null) { return; } WebSocket.CloseAsync(); WebSocket.OnOpen -= WebSocket_OnOpen; WebSocket.OnMessage -= WebSocket_OnMessage; WebSocket.OnError -= WebSocket_OnError; WebSocket.OnClose -= WebSocket_OnClose; WebSocket = null; #endif }