@@ -42,7 +42,7 @@ public ConnectionManager(IServiceProvider serviceProvider,
4242 Connections = new ConcurrentDictionary < string , WebSocketTransport > ( StringComparer . OrdinalIgnoreCase ) ;
4343 }
4444
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 )
4646 {
4747 if ( body == null )
4848 {
@@ -67,7 +67,7 @@ private async Task<byte[]> PrepareFramesBytesAsync(byte[] body, IDictionary<stri
6767
6868 _headerProvider . Invoke ( properties ) ;
6969 string props = JsonConvert . SerializeObject ( properties ) ;
70- byte [ ] header = Encoding . UTF8 . GetBytes ( $ " { props } " ) ;
70+ byte [ ] header = Encoding . UTF8 . GetBytes ( props ) ;
7171
7272 if ( ! compressed )
7373 {
@@ -187,22 +187,21 @@ public async Task BroadcastBinaryAsync(byte[] inputs, IDictionary<string, object
187187 return ;
188188 }
189189
190- var bytes = await PrepareFramesBytesAsync ( inputs , properties ) ;
190+ var bytes = await ToBytesAsync ( inputs , properties ) ;
191191 using ( var stream = new MemoryStream ( bytes ) )
192192 {
193193 await SendDataAsync ( stream , WebSocketMessageType . Binary , Connections . Select ( c => c . Key ) . ToArray ( ) ) ;
194194 }
195195 }
196196
197- public async Task BroadcastAsync ( byte [ ] inputs , IDictionary < string , object > properties = null )
197+ public async Task BroadcastAsync ( byte [ ] inputs )
198198 {
199199 if ( ! Connections . Any ( ) )
200200 {
201201 return ;
202202 }
203203
204- var bytes = await PrepareFramesBytesAsync ( inputs , properties ) ;
205- using ( var stream = new MemoryStream ( bytes ) )
204+ using ( var stream = new MemoryStream ( inputs ) )
206205 {
207206 await SendDataAsync ( stream , WebSocketMessageType . Text , Connections . Select ( c => c . Key ) . ToArray ( ) ) ;
208207 }
@@ -217,7 +216,7 @@ public async Task BroadcastBinaryAsync(WebSocketMessageContext context)
217216
218217 using ( var ms = context . ToMemoryStream ( ) )
219218 {
220- var bytes = await PrepareFramesBytesAsync ( ms . ToArray ( ) ) ;
219+ var bytes = await ToBytesAsync ( ms . ToArray ( ) ) ;
221220 using ( var stream = new MemoryStream ( bytes ) )
222221 {
223222 await SendDataAsync ( stream , WebSocketMessageType . Binary , Connections . Select ( c => c . Key ) . ToArray ( ) ) ;
@@ -251,7 +250,7 @@ public async Task SendBinaryAsync(string connectionId, byte[] input, IDictionary
251250 throw new ArgumentOutOfRangeException ( nameof ( transport ) ) ;
252251 }
253252
254- byte [ ] bytes = await PrepareFramesBytesAsync ( input , properties ) ;
253+ byte [ ] bytes = await ToBytesAsync ( input , properties ) ;
255254 using ( var stream = new MemoryStream ( bytes ) )
256255 {
257256 await SendDataAsync ( stream , WebSocketMessageType . Binary , connectionId ) ;
0 commit comments