/// <summary> /// 停止udp监听 /// </summary> public void StopListening() { if (!isRunning) { return; } isRunning = false; #if !UNITY_EDITOR && UNITY_WSA upClient.StopListening(); upClient.OnReceiveData -= OnReceiveData; #else try { socket.Dispose(); socket = null; udpSendSocket.UnInit(); udpReceiveSocket.OnReceiveData -= OnReceiveData; } catch (Exception e) { print("!UnInitUdpNet error: " + e.Message + ", " + e.StackTrace); } #endif print("UnInitUdpNet OK!"); }
/// <summary> /// 停止udp监听 /// </summary> public void StopListening() { if (!isRunning) { return; } isRunning = false; try { socket.Dispose(); socket = null; udpSendSocket.UnInit(); udpReceiveSocket.OnReceiveData -= OnReceiveData; } catch (Exception e) { Debug.LogError("!UnInitUdpNet error: " + e.Message + ", " + e.StackTrace); } Debug.Log("UnInitUdpNet OK!"); }