public void OnDisable() { if (sender != null) { SendBeacon(false); } stopSender?.Set(); stopCleaner?.Set(); if (broadcast != null) { broadcast.onReceive.RemoveListener(OnReceive); } sender?.Join(); cleaner?.Join(); stopSender?.Dispose(); stopCleaner?.Dispose(); discovered.Clear(); sender = null; cleaner = null; stopSender = null; stopCleaner = null; }
protected void OnDestroy() { stop.Set(); thread.Join(); udp.Dispose(); stop.Dispose(); udp = null; thread = null; stop = null; }
protected void Dispose(bool disposing) { if (!disposed) { disposed = true; lock (sendQueue) { sendQueue.Clear(); } DisposeInternal(disposing); if (disposing) { // TODO: delete managed state (managed objects). stopEvent.Set(); if (listen) { worker.Join(); } } // TODO: free unmanaged resources (unmanaged objects) and replace finalizer below. // TODO: set fields of large size with null value. Threads.APC.MonoBehaviourCall.Instance.Call(() => { if (events.onDisconnectedHandler != null) { events.onDisconnectedHandler.Invoke(this); } if (events.onDisconnected != null) { events.onDisconnected.Invoke(address, parameters.guid, parameters.channel); } }); } }
protected virtual void Dispose(bool disposing) { if(!disposed) { if(disposing) { // TODO: delete managed state (managed objects). listener.Stop(); stopEvent.Set(); listenerWorker.Join(); stopEvent.Close(); } // TODO: free unmanaged resources (unmanaged objects) and replace finalizer below. // TODO: set fields of large size with null value. disposed = true; } }
public override void Disconnect() { if (state == State.RUNNING || state == State.CLOSING) { if (listener != null) { listener.Stop(); } if (stopEvent != null) { stopEvent.Set(); } CloseInitializedConnections(); CloseOpenedChannels(); CloseMonitors(); if (listenerThread != null) { listenerThread.Join(); } if (stopEvent != null) { stopEvent.Close(); } serverCertificate = null; listenerThread = null; stopEvent = null; state = State.STARTED; } }