mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-18 23:39:29 +00:00
Add extension to recycle websockets (#50)
Signed-off-by: Macocian Alexandru Victor <amacocian@yahoo.com>
This commit is contained in:
@@ -9,7 +9,7 @@ namespace System.Net.WebSockets;
|
||||
public sealed class ClientWebSocket<TScope> : IClientWebSocket<TScope>, IDisposable
|
||||
{
|
||||
private readonly ILogger<TScope>? logger;
|
||||
private readonly ClientWebSocket internalWebSocket = new();
|
||||
private ClientWebSocket internalWebSocket = new();
|
||||
|
||||
public ClientWebSocketOptions Options => this.internalWebSocket.Options;
|
||||
|
||||
@@ -89,4 +89,10 @@ public sealed class ClientWebSocket<TScope> : IClientWebSocket<TScope>, IDisposa
|
||||
scopedLogger?.LogDebug($"Type: {messageType}\nCount: {buffer.Count}\nEndOfMessage: {endOfMessage}");
|
||||
return this.internalWebSocket.SendAsync(buffer, messageType, endOfMessage, cancellationToken);
|
||||
}
|
||||
|
||||
public void RefreshSocket(ClientWebSocket? clientWebSocket = null)
|
||||
{
|
||||
this.internalWebSocket?.Dispose();
|
||||
this.internalWebSocket = clientWebSocket ?? new ClientWebSocket();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user