Skip to content

Commit bf47adb

Browse files
Gourav DwivediGourav Dwivedi
authored andcommitted
Added Test Hub to dotnet core sample application
1 parent 78591ad commit bf47adb

File tree

1 file changed

+36
-0
lines changed
  • Samples/AspDotCore/WebApp/WebApp/Hubs

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.AspNetCore.SignalR;
2+
using System;
3+
using System.Threading.Tasks;
4+
5+
namespace WebApp.Hubs
6+
{
7+
public class OneHub : Hub
8+
{
9+
public override Task OnConnectedAsync()
10+
{
11+
return base.OnConnectedAsync();
12+
}
13+
14+
public async Task NotifySameClient(string data)
15+
{
16+
var connectionId = Context.ConnectionId;
17+
await Clients.Client(connectionId).SendAsync("ReceiveData", $"Data Received: {data}");
18+
}
19+
20+
public async Task NotifyAllClient(string data)
21+
{
22+
await Clients.All.SendAsync("ReceiveData", $"Data Received: {data}");
23+
}
24+
25+
public async Task TestComplexData(string data)
26+
{
27+
var connectionId = Context.ConnectionId;
28+
await Clients.Client(connectionId).SendAsync("ReceiveData", $"Data Received: {data}");
29+
}
30+
31+
public override Task OnDisconnectedAsync(Exception exception)
32+
{
33+
return base.OnDisconnectedAsync(exception);
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)