Skip to content

Commit e6467ea

Browse files
committed
change HubArgument to interface and fixing one error message
1 parent 8e8e001 commit e6467ea

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

src/ResponseCrafter/ExceptionHandlers/SignalR/HubArgument.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace ResponseCrafter.ExceptionHandlers.SignalR;
22

3-
internal interface IHubArgument
3+
public interface IHubArgument
44
{
55
public string InvocationId { get; set; }
66
}

src/ResponseCrafter/ExceptionHandlers/SignalR/SignalRExceptionFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public SignalRExceptionFilter(ILogger<SignalRExceptionFilter> logger,
3636

3737
try
3838
{
39-
invocationId = TryGetInvocationId<HubArgument>(invocationContext);
39+
invocationId = TryGetInvocationId<IHubArgument>(invocationContext);
4040
return await next(invocationContext);
4141
}
4242
catch (DbUpdateConcurrencyException)
@@ -63,7 +63,7 @@ private static string TryGetInvocationId<T>(HubInvocationContext hubInvocationCo
6363
{
6464
if (hubInvocationContext.HubMethodArguments is not [T hubArgument])
6565
{
66-
throw new BadRequestException("Invalid hub method arguments. Expected a single HubArgument<T> parameter.");
66+
throw new BadRequestException("Invalid hub method arguments. Request model does not implement IHubArgument interface.");
6767
}
6868

6969
var invocationId = hubArgument.InvocationId;

src/ResponseCrafter/ResponseCrafter.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<Copyright>MIT</Copyright>
99
<PackageIcon>pandatech.png</PackageIcon>
1010
<PackageReadmeFile>Readme.md</PackageReadmeFile>
11-
<Version>5.1.7</Version>
11+
<Version>5.1.8</Version>
1212
<PackageId>Pandatech.ResponseCrafter</PackageId>
1313
<PackageTags>Pandatech, library, exception handler, exception, middleware, Api response</PackageTags>
1414
<Title>ResponseCrafter</Title>
1515
<Description>Handling exceptions, custom Dtos.</Description>
1616
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-response-crafter</RepositoryUrl>
17-
<PackageReleaseNotes>nuget updates</PackageReleaseNotes>
17+
<PackageReleaseNotes>Changing HubArgument to interface and fixing one comment</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

test/ResponseCrafter.Demo/Hubs/ChatHub.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Microsoft.AspNetCore.SignalR;
2-
using ResponseCrafter.Helpers;
2+
using ResponseCrafter.ExceptionHandlers.SignalR;
33
using ResponseCrafter.HttpExceptions;
44

55
namespace ResponseCrafter.Demo.Hubs;
@@ -12,15 +12,16 @@ public override async Task OnConnectedAsync()
1212
await base.OnConnectedAsync();
1313
}
1414

15-
public async Task SendMessage(HubArgument<Message> hubArgument)
15+
public async Task SendMessage(Message hubArgument)
1616
{
1717
throw new BadRequestException("This is a test exception");
18-
await Clients.All.ReceiveMessage(hubArgument.Argument);
18+
await Clients.All.ReceiveMessage(hubArgument.User);
1919
}
2020
}
2121

22-
public class Message
22+
public class Message : IHubArgument
2323
{
2424
public required string User { get; set; }
2525
public required string Content { get; set; }
26+
public required string InvocationId { get; set; }
2627
}

0 commit comments

Comments
 (0)