Code cleanup for network module.

This commit is contained in:
2023-07-11 00:02:14 +08:00
parent c9b348dd4f
commit d89423caf5
4 changed files with 38 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ using Org.BouncyCastle.Security;
using Org.BouncyCastle.Tls;
using Org.BouncyCastle.Tls.Crypto;
using Org.BouncyCastle.Tls.Crypto.Impl.BC;
using System;
using System.Collections;
using System.IO;
using System.Linq;
@@ -9,7 +10,7 @@ using System.Text;
using BcTlsClient = Org.BouncyCastle.Tls.TlsClient;
namespace Cryville.Common.Network {
public class TlsClient {
public class TlsClient : IDisposable {
readonly TlsClientProtocol _protocol;
readonly BcTlsClient _tlsClient;
public Stream Stream { get; private set; }
@@ -27,6 +28,16 @@ namespace Cryville.Common.Network {
_protocol.Close();
}
public void Dispose() {
Dispose(true);
}
public virtual void Dispose(bool disposing) {
if (disposing) {
Close();
}
}
private class InternalTlsClient : DefaultTlsClient {
readonly string _host;