mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 14:19:29 +00:00
Client Web Socket fix (#49)
* Fix for clientwebsocket * Updated dependencies
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<RootNamespace>System</RootNamespace>
|
||||
<Version>1.6</Version>
|
||||
<Version>1.6.1</Version>
|
||||
<Authors>Alexandru Macocian</Authors>
|
||||
<RepositoryUrl>https://github.com/AlexMacocian/SystemExtensions</RepositoryUrl>
|
||||
<Description>Extensions for the System namespace</Description>
|
||||
@@ -23,8 +23,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -38,11 +38,15 @@ public sealed class ClientWebSocket<TScope> : IClientWebSocket<TScope>, IDisposa
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
var scopedLogger = this.logger?.CreateScopedLogger(nameof(Dispose), string.Empty);
|
||||
scopedLogger?.LogInformation($"Disposing websocket");
|
||||
this.internalWebSocket?.Dispose();
|
||||
}
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
var scopedLogger = this.logger?.CreateScopedLogger(nameof(Abort), string.Empty);
|
||||
scopedLogger?.LogInformation($"Aborting websocket");
|
||||
this.internalWebSocket.Abort();
|
||||
}
|
||||
|
||||
@@ -64,14 +68,14 @@ public sealed class ClientWebSocket<TScope> : IClientWebSocket<TScope>, IDisposa
|
||||
{
|
||||
var scopedLogger = this.logger?.CreateScopedLogger(nameof(ConnectAsync), string.Empty);
|
||||
scopedLogger?.LogInformation($"Connecting to {uri}");
|
||||
return this.ConnectAsync(uri, cancellationToken);
|
||||
return this.internalWebSocket.ConnectAsync(uri, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<WebSocketReceiveResult> ReceiveAsync(ArraySegment<byte> buffer, CancellationToken cancellationToken)
|
||||
{
|
||||
var scopedLogger = this.logger?.CreateScopedLogger(nameof(ConnectAsync), string.Empty);
|
||||
scopedLogger?.LogInformation($"Attempting to receive bytes");
|
||||
var result = await this.ReceiveAsync(buffer, cancellationToken);
|
||||
var result = await this.internalWebSocket.ReceiveAsync(buffer, cancellationToken);
|
||||
scopedLogger?.LogInformation($"Received message [{result.MessageType}]");
|
||||
scopedLogger?.LogDebug($"Type: {result.MessageType}\nCount: {result.Count}\nEndOfMessage: {result.EndOfMessage}\nCloseStatus: {result.CloseStatus}\nCloseStatusDescription: {result.CloseStatusDescription}");
|
||||
|
||||
@@ -83,6 +87,6 @@ public sealed class ClientWebSocket<TScope> : IClientWebSocket<TScope>, IDisposa
|
||||
var scopedLogger = this.logger?.CreateScopedLogger(nameof(SendAsync), string.Empty);
|
||||
scopedLogger?.LogInformation($"Sending bytes");
|
||||
scopedLogger?.LogDebug($"Type: {messageType}\nCount: {buffer.Count}\nEndOfMessage: {endOfMessage}");
|
||||
return this.SendAsync(buffer, messageType, endOfMessage, cancellationToken);
|
||||
return this.internalWebSocket.SendAsync(buffer, messageType, endOfMessage, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user