public override void Dispose() { if (this.IsDisposed) { return; } base.Dispose(); try { if (this.Error == ErrorCode.ERR_Success) { for (int i = 0; i < 4; i++) { this.Disconnect(); } } } catch (Exception) { // ignored } if (this.kcp != IntPtr.Zero) { Kcp.KcpRelease(this.kcp); this.kcp = IntPtr.Zero; } this.socket = null; this.memoryStream.Dispose(); }
public override void Dispose() { if (this.IsDisposed) { return; } uint localConn = this.LocalConn; uint remoteConn = this.RemoteConn; Log.Info($"channel dispose: {this.Id} {localConn} {remoteConn}"); kChannels.Remove(localConn); idLocalRemoteConn.Remove(this.Id); // idLocalRemoteConn.TryRemove(this.Id, out ulong _); long id = this.Id; this.Id = 0; this.Service.Remove(id); try { //this.Service.Disconnect(localConn, remoteConn, this.Error, this.RemoteAddress, 3); } catch (Exception e) { Log.Error(e); } if (this.kcp != IntPtr.Zero) { Kcp.KcpRelease(this.kcp); this.kcp = IntPtr.Zero; } this.socket = null; }