File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/BootstrapBlazor.Server/Components/Samples/Sockets Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ namespace BootstrapBlazor.Server.Components.Samples.Sockets;
1010/// <summary>
1111/// 接收电文示例
1212/// </summary>
13- public partial class Receives : ComponentBase , IDisposable
13+ public partial class Receives : IDisposable
1414{
1515 [ Inject , NotNull ]
1616 private ITcpSocketFactory ? TcpSocketFactory { get ; set ; }
@@ -19,6 +19,8 @@ public partial class Receives : ComponentBase, IDisposable
1919
2020 private List < ConsoleMessageItem > _items = [ ] ;
2121
22+ private readonly IPEndPoint _serverEndPoint = new ( IPAddress . Loopback , 8800 ) ;
23+
2224 /// <summary>
2325 /// <inheritdoc/>
2426 /// </summary>
@@ -27,7 +29,7 @@ protected override void OnInitialized()
2729 base . OnInitialized ( ) ;
2830
2931 // 从服务中获取 Socket 实例
30- _client = TcpSocketFactory . GetOrCreate ( "bb " , options =>
32+ _client = TcpSocketFactory . GetOrCreate ( "demo-receive " , options =>
3133 {
3234 options . LocalEndPoint = new IPEndPoint ( IPAddress . Loopback , 0 ) ;
3335 } ) ;
@@ -38,7 +40,7 @@ private async Task OnConnectAsync()
3840 {
3941 if ( _client is { IsConnected : false } )
4042 {
41- await _client . ConnectAsync ( "127.0.0.1" , 8800 , CancellationToken . None ) ;
43+ await _client . ConnectAsync ( _serverEndPoint , CancellationToken . None ) ;
4244 }
4345 }
4446
You can’t perform that action at this time.
0 commit comments