@@ -23,14 +23,14 @@ public class ChatComponent : ComponentBase
23
23
24
24
private IDisposable objectHandle ;
25
25
private IDisposable listHandle ;
26
- private IDisposable _multiArgsHandle ;
27
- private IDisposable _multiArgsComplexHandle ;
28
- private IDisposable _byteArrayHandle ;
29
- private HubConnection _connection ;
26
+ private IDisposable multiArgsHandle ;
27
+ private IDisposable multiArgsComplexHandle ;
28
+ private IDisposable byteArrayHandle ;
29
+ private HubConnection connection ;
30
30
31
31
protected override async Task OnInitAsync ( )
32
32
{
33
- this . _connection = this . _hubConnectionBuilder
33
+ this . connection = this . _hubConnectionBuilder
34
34
. WithUrl ( "/chathub" ,
35
35
opt =>
36
36
{
@@ -47,13 +47,13 @@ protected override async Task OnInitAsync()
47
47
//.AddMessagePackProtocol()
48
48
. Build ( ) ;
49
49
50
- this . _connection . On < string > ( "Send" , this . Handle ) ;
51
- this . _connection . OnClose ( exc =>
50
+ this . connection . On < string > ( "Send" , this . Handle ) ;
51
+ this . connection . OnClose ( exc =>
52
52
{
53
53
Console . WriteLine ( "Connection was closed! " + exc . ToString ( ) ) ;
54
54
return Task . CompletedTask ;
55
55
} ) ;
56
- await this . _connection . StartAsync ( ) ;
56
+ await this . connection . StartAsync ( ) ;
57
57
}
58
58
59
59
public Task DemoMethodObject ( object data )
@@ -77,23 +77,23 @@ public Task DemoMethodList(object data)
77
77
public Task DemoMultipleArgs ( string arg1 , int arg2 , string arg3 , int arg4 )
78
78
{
79
79
Console . WriteLine ( "Got Multiple Args!" ) ;
80
- this . _multiArgsHandle . Dispose ( ) ;
80
+ this . multiArgsHandle . Dispose ( ) ;
81
81
82
82
return this . HandleArgs ( arg1 , arg2 , arg3 , arg4 ) ;
83
83
}
84
84
85
85
public Task DemoMultipleArgsComplex ( object arg1 , object arg2 )
86
86
{
87
87
Console . WriteLine ( "Got Multiple Args Complex!" ) ;
88
- this . _multiArgsComplexHandle . Dispose ( ) ;
88
+ this . multiArgsComplexHandle . Dispose ( ) ;
89
89
90
90
return this . HandleArgs ( arg1 , arg2 ) ;
91
91
}
92
92
93
93
public Task DemoByteArrayArg ( byte [ ] array )
94
94
{
95
95
Console . WriteLine ( "Got byte array!" ) ;
96
- this . _byteArrayHandle . Dispose ( ) ;
96
+ this . byteArrayHandle . Dispose ( ) ;
97
97
98
98
return this . HandleArgs ( BitConverter . ToString ( array ) ) ;
99
99
}
@@ -125,65 +125,65 @@ private Task HandleArgs(params object[] args)
125
125
126
126
internal async Task Broadcast ( )
127
127
{
128
- await this . _connection . InvokeAsync ( "Send" , this . ToEverybody ) ;
128
+ await this . connection . InvokeAsync ( "Send" , this . ToEverybody ) ;
129
129
}
130
130
131
131
internal async Task SendToOthers ( )
132
132
{
133
- await this . _connection . InvokeAsync ( "SendToOthers" , this . ToEverybody ) ;
133
+ await this . connection . InvokeAsync ( "SendToOthers" , this . ToEverybody ) ;
134
134
}
135
135
136
136
internal async Task SendToConnection ( )
137
137
{
138
- await this . _connection . InvokeAsync ( "SendToConnection" , this . ConnectionId , this . ToConnection ) ;
138
+ await this . connection . InvokeAsync ( "SendToConnection" , this . ConnectionId , this . ToConnection ) ;
139
139
}
140
140
141
141
internal async Task SendToMe ( )
142
142
{
143
- await this . _connection . InvokeAsync ( "Echo" , this . ToMe ) ;
143
+ await this . connection . InvokeAsync ( "Echo" , this . ToMe ) ;
144
144
}
145
145
146
146
internal async Task SendToGroup ( )
147
147
{
148
- await this . _connection . InvokeAsync ( "SendToGroup" , this . GroupName , this . ToGroup ) ;
148
+ await this . connection . InvokeAsync ( "SendToGroup" , this . GroupName , this . ToGroup ) ;
149
149
}
150
150
151
151
internal async Task SendToOthersInGroup ( )
152
152
{
153
- await this . _connection . InvokeAsync ( "SendToOthersInGroup" , this . GroupName , this . ToGroup ) ;
153
+ await this . connection . InvokeAsync ( "SendToOthersInGroup" , this . GroupName , this . ToGroup ) ;
154
154
}
155
155
156
156
internal async Task JoinGroup ( )
157
157
{
158
- await this . _connection . InvokeAsync ( "JoinGroup" , this . GroupName ) ;
158
+ await this . connection . InvokeAsync ( "JoinGroup" , this . GroupName ) ;
159
159
}
160
160
161
161
internal async Task LeaveGroup ( )
162
162
{
163
- await this . _connection . InvokeAsync ( "LeaveGroup" , this . GroupName ) ;
163
+ await this . connection . InvokeAsync ( "LeaveGroup" , this . GroupName ) ;
164
164
}
165
165
166
166
internal async Task DoMultipleArgs ( )
167
167
{
168
- this . _multiArgsHandle = this . _connection . On < string , int , string , int > ( "DemoMultiArgs" , this . DemoMultipleArgs ) ;
169
- this . _multiArgsComplexHandle = this . _connection . On < DemoData , DemoData [ ] > ( "DemoMultiArgs2" , this . DemoMultipleArgsComplex ) ;
170
- await this . _connection . InvokeAsync ( "DoMultipleArgs" ) ;
171
- await this . _connection . InvokeAsync ( "DoMultipleArgsComplex" ) ;
168
+ this . multiArgsHandle = this . connection . On < string , int , string , int > ( "DemoMultiArgs" , this . DemoMultipleArgs ) ;
169
+ this . multiArgsComplexHandle = this . connection . On < DemoData , DemoData [ ] > ( "DemoMultiArgs2" , this . DemoMultipleArgsComplex ) ;
170
+ await this . connection . InvokeAsync ( "DoMultipleArgs" ) ;
171
+ await this . connection . InvokeAsync ( "DoMultipleArgsComplex" ) ;
172
172
}
173
173
174
174
internal async Task DoByteArrayArg ( )
175
175
{
176
- this . _byteArrayHandle = this . _connection . On < byte [ ] > ( "DemoByteArrayArg" , this . DemoByteArrayArg ) ;
177
- var array = await this . _connection . InvokeAsync < byte [ ] > ( "DoByteArrayArg" ) ;
176
+ this . byteArrayHandle = this . connection . On < byte [ ] > ( "DemoByteArrayArg" , this . DemoByteArrayArg ) ;
177
+ var array = await this . connection . InvokeAsync < byte [ ] > ( "DoByteArrayArg" ) ;
178
178
179
179
Console . WriteLine ( "Got byte returned from hub method array: {0}" , BitConverter . ToString ( array ) ) ;
180
180
}
181
181
182
182
internal async Task TellHubToDoStuff ( )
183
183
{
184
- this . objectHandle = this . _connection . On < DemoData > ( "DemoMethodObject" , this . DemoMethodObject ) ;
185
- this . listHandle = this . _connection . On < DemoData [ ] > ( "DemoMethodList" , this . DemoMethodList ) ;
186
- await this . _connection . InvokeAsync ( "DoSomething" ) ;
184
+ this . objectHandle = this . connection . On < DemoData > ( "DemoMethodObject" , this . DemoMethodObject ) ;
185
+ this . listHandle = this . connection . On < DemoData [ ] > ( "DemoMethodList" , this . DemoMethodList ) ;
186
+ await this . connection . InvokeAsync ( "DoSomething" ) ;
187
187
}
188
188
}
189
189
}
0 commit comments