Skip to content

Commit e4da74a

Browse files
committed
feat: LocalEndPoint 更改未可为空
1 parent 32b62f6 commit e4da74a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/BootstrapBlazor/Services/TcpSocket/DefaultTcpSocketClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sealed class DefaultTcpSocketClient(IPEndPoint localEndPoint) : ITcpSocketClient
2121

2222
public bool IsConnected => _client?.Connected ?? false;
2323

24-
public IPEndPoint LocalEndPoint => localEndPoint;
24+
public IPEndPoint? LocalEndPoint { get; set; }
2525

2626
[NotNull]
2727
public ILogger<DefaultTcpSocketClient>? Logger { get; set; }
@@ -237,10 +237,11 @@ private void Dispose(bool disposing)
237237
{
238238
if (disposing)
239239
{
240+
LocalEndPoint = null;
240241
_remoteEndPoint = null;
241242

242243
// 取消接收数据的任务
243-
if (_receiveCancellationTokenSource is not null)
244+
if (_receiveCancellationTokenSource != null)
244245
{
245246
_receiveCancellationTokenSource.Cancel();
246247
_receiveCancellationTokenSource.Dispose();

src/BootstrapBlazor/Services/TcpSocket/ITcpSocketClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public interface ITcpSocketClient : IDisposable
5353
/// <remarks>This property provides information about the local endpoint of the socket, which is typically
5454
/// used to identify the local address and port being used for communication. If the socket is not bound to a
5555
/// specific local endpoint, this property may return <see langword="null"/>.</remarks>
56-
IPEndPoint LocalEndPoint { get; }
56+
IPEndPoint? LocalEndPoint { get; }
5757

5858
/// <summary>
5959
/// Gets or sets the callback function to handle received data.

0 commit comments

Comments
 (0)