Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nenoNaninu committed Jan 9, 2024
1 parent fd98a70 commit a0d2f9d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/Server/Hubs/InheritHub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.AspNetCore.SignalR;
using Shared;

namespace Server.Hubs;

public class InheritHub : Hub<IUnaryHubReceiver>, IInheritHub
{
private readonly ILogger<InheritHub> _logger;

public InheritHub(ILogger<InheritHub> logger)
{
_logger = logger;
}

public Task<int> Add(int x, int y)
{
return Task.FromResult(x + y);
}

public Task<string> Cat(string x, string y)
{
return Task.FromResult(x + y);
}

public Task<UserDefinedType> Echo(UserDefinedType instance)
{
return Task.FromResult(instance);
}

public Task<string> Get()
{
return Task.FromResult("TypedSignalR.Client.DevTools");
}
}
2 changes: 2 additions & 0 deletions examples/Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@
app.MapHub<AuthUnaryHub>("/hubs/AuthUnaryHub");
app.MapHub<AuthUnaryHub2>("/hubs/AuthUnaryHub2");

app.MapHub<InheritHub>("/hubs/InheritHub");

app.Run();
30 changes: 30 additions & 0 deletions examples/Shared/IInheritHub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Threading.Tasks;
using TypedSignalR.Client;

namespace Shared;

public interface IHubBaseBase
{
Task<string> Get();
}

public interface IHubBase1 : IHubBaseBase
{
Task<int> Add(int x, int y);
}

public interface IHubBase2 : IHubBaseBase
{
Task<string> Cat(string x, string y);
}

[Hub]
public interface IInheritHub : IHubBase1, IHubBase2
{
Task<UserDefinedType> Echo(UserDefinedType instance);
}

[Receiver]
public interface IInheritHubReceiver
{
}

0 comments on commit a0d2f9d

Please sign in to comment.