Skip to content

Commit

Permalink
feat: RsaStream 重写自己的 Dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed Aug 13, 2024
1 parent 0b1404d commit 6e30275
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Network/RsaStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace TeraIO.Network;

public class RsaStream : Stream
public class RsaStream : Stream, IDisposable
{
protected readonly Stream _stream;
protected RSA _rsaPrivate;
Expand Down Expand Up @@ -225,4 +225,17 @@ public override void Close()
}

#endregion

#region IDisposable Overrides
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
this.Close();
_stream.Dispose();
this.Status = RsaStreamStatus.Disposed;
}
}
#endregion
}
1 change: 1 addition & 0 deletions Network/RsaStreamStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum RsaStreamStatus
Handshaking,
Established,
Closed,
Disposed,
Failed = 100,
AuthenticationFailed = 101,
ProtocolVersionMismatch = 102
Expand Down

0 comments on commit 6e30275

Please sign in to comment.