Skip to content

Commit e97d259

Browse files
committed
refactor: 重构 DefaultTcpSocketFactory 实现类
1 parent 489d284 commit e97d259

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/extensions/BootstrapBlazor.TouchSocket/Services/DefaultTcpSocketFactory.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DefaultTcpSocketFactory(IServiceProvider provider) : ITcpSocketFactory
1212
{
1313
private readonly ConcurrentDictionary<string, ITcpSocketClient> _pool = new();
1414

15-
public ITcpSocketClient GetOrCreate(string host, int port = 0, SocketMode mode = SocketMode.Client)
15+
public ITcpSocketClient GetOrCreate(string host, int port = 0)
1616
{
1717
return _pool.GetOrAdd($"{host}:{port}", key =>
1818
{
@@ -24,6 +24,16 @@ public ITcpSocketClient GetOrCreate(string host, int port = 0, SocketMode mode =
2424
});
2525
}
2626

27+
public ITcpSocketClient? Remove(string host, int port)
28+
{
29+
ITcpSocketClient? client = null;
30+
if (_pool.TryRemove($"{host}:{port}", out var c))
31+
{
32+
client = c;
33+
}
34+
return client;
35+
}
36+
2737
private void Dispose(bool disposing)
2838
{
2939
if (disposing)

0 commit comments

Comments
 (0)