Пример #1
0
        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
        }
Пример #2
0
        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
        }