File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Samples/AspDotCore/WebApp/WebApp/Hubs Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments