@@ -42,7 +42,7 @@ public ConnectionManager(IServiceProvider serviceProvider,
42
42
Connections = new ConcurrentDictionary < string , WebSocketTransport > ( StringComparer . OrdinalIgnoreCase ) ;
43
43
}
44
44
45
- private async Task < byte [ ] > PrepareFramesBytesAsync ( byte [ ] body , IDictionary < string , object > properties = null )
45
+ private async Task < byte [ ] > ToBytesAsync ( byte [ ] body , IDictionary < string , object > properties = null )
46
46
{
47
47
if ( body == null )
48
48
{
@@ -67,7 +67,7 @@ private async Task<byte[]> PrepareFramesBytesAsync(byte[] body, IDictionary<stri
67
67
68
68
_headerProvider . Invoke ( properties ) ;
69
69
string props = JsonConvert . SerializeObject ( properties ) ;
70
- byte [ ] header = Encoding . UTF8 . GetBytes ( $ " { props } " ) ;
70
+ byte [ ] header = Encoding . UTF8 . GetBytes ( props ) ;
71
71
72
72
if ( ! compressed )
73
73
{
@@ -187,22 +187,21 @@ public async Task BroadcastBinaryAsync(byte[] inputs, IDictionary<string, object
187
187
return ;
188
188
}
189
189
190
- var bytes = await PrepareFramesBytesAsync ( inputs , properties ) ;
190
+ var bytes = await ToBytesAsync ( inputs , properties ) ;
191
191
using ( var stream = new MemoryStream ( bytes ) )
192
192
{
193
193
await SendDataAsync ( stream , WebSocketMessageType . Binary , Connections . Select ( c => c . Key ) . ToArray ( ) ) ;
194
194
}
195
195
}
196
196
197
- public async Task BroadcastAsync ( byte [ ] inputs , IDictionary < string , object > properties = null )
197
+ public async Task BroadcastAsync ( byte [ ] inputs )
198
198
{
199
199
if ( ! Connections . Any ( ) )
200
200
{
201
201
return ;
202
202
}
203
203
204
- var bytes = await PrepareFramesBytesAsync ( inputs , properties ) ;
205
- using ( var stream = new MemoryStream ( bytes ) )
204
+ using ( var stream = new MemoryStream ( inputs ) )
206
205
{
207
206
await SendDataAsync ( stream , WebSocketMessageType . Text , Connections . Select ( c => c . Key ) . ToArray ( ) ) ;
208
207
}
@@ -217,7 +216,7 @@ public async Task BroadcastBinaryAsync(WebSocketMessageContext context)
217
216
218
217
using ( var ms = context . ToMemoryStream ( ) )
219
218
{
220
- var bytes = await PrepareFramesBytesAsync ( ms . ToArray ( ) ) ;
219
+ var bytes = await ToBytesAsync ( ms . ToArray ( ) ) ;
221
220
using ( var stream = new MemoryStream ( bytes ) )
222
221
{
223
222
await SendDataAsync ( stream , WebSocketMessageType . Binary , Connections . Select ( c => c . Key ) . ToArray ( ) ) ;
@@ -251,7 +250,7 @@ public async Task SendBinaryAsync(string connectionId, byte[] input, IDictionary
251
250
throw new ArgumentOutOfRangeException ( nameof ( transport ) ) ;
252
251
}
253
252
254
- byte [ ] bytes = await PrepareFramesBytesAsync ( input , properties ) ;
253
+ byte [ ] bytes = await ToBytesAsync ( input , properties ) ;
255
254
using ( var stream = new MemoryStream ( bytes ) )
256
255
{
257
256
await SendDataAsync ( stream , WebSocketMessageType . Binary , connectionId ) ;
0 commit comments