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 37d396a commit 114be57
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
13 changes: 8 additions & 5 deletions examples/Server/Hubs/InheritHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Server.Hubs;

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

Expand All @@ -17,14 +17,17 @@ public Task<int> Add(int x, int y)
return Task.FromResult(x + y);
}

public Task<string> Cat(string x, string y)
public async Task<string> Cat(string x, string y)
{
return Task.FromResult(x + y);
var str = x + y;
await this.Clients.All.ReceiveMessage(str, str.Length);
return str;
}

public Task<UserDefinedType> Echo(UserDefinedType instance)
public async Task<UserDefinedType> Echo(UserDefinedType instance)
{
return Task.FromResult(instance);
await this.Clients.All.ReceiveCustomMessage(instance);
return instance;
}

public Task<string> Get()
Expand Down
19 changes: 18 additions & 1 deletion examples/Shared/IInheritHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@ public interface IInheritHub : IHubBase1, IHubBase2
Task<UserDefinedType> Echo(UserDefinedType instance);
}


public interface IReceiverBaseBase
{
Task ReceiveMessage(string message, int value);
}

public interface IReceiverBase1 : IReceiverBaseBase
{
Task ReceiveCustomMessage(UserDefinedType userDefined);
}

public interface IReceiverBase2 : IReceiverBaseBase
{
Task Notify();
}

[Receiver]
public interface IInheritHubReceiver
public interface IInheritReceiver : IReceiverBase1, IReceiverBase2
{
Task ReceiveMessage2(string message, int value);
}

0 comments on commit 114be57

Please sign in to comment.