File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 <PackageTags >cTrader, Open API, Spotware</PackageTags >
1010 <Description >A .NET RX library for Spotware Open API</Description >
1111 <PackageId >Spotware.OpenAPI.Net</PackageId >
12- <Version >1.3.9 </Version >
12+ <Version >1.4.0-rc0 </Version >
1313 <Platforms >AnyCPU</Platforms >
1414 <Company >Spotware</Company >
1515 <Authors >Spotware</Authors >
Original file line number Diff line number Diff line change 1313using Websocket . Client ;
1414using System . Net . WebSockets ;
1515using System . Threading . Channels ;
16+ using System . Buffers ;
1617
1718namespace OpenAPI . Net
1819{
@@ -376,11 +377,12 @@ private async Task StartSendingMessages(CancellationToken cancellationToken)
376377 /// <returns>Task</returns>
377378 private async void ReadTcp ( CancellationToken cancellationToken )
378379 {
380+ var lengthArray = new byte [ sizeof ( int ) ] ;
381+
379382 try
380383 {
381384 while ( ! IsDisposed )
382385 {
383- var lengthArray = new byte [ sizeof ( int ) ] ;
384386
385387 var readBytes = 0 ;
386388
@@ -400,7 +402,7 @@ private async void ReadTcp(CancellationToken cancellationToken)
400402
401403 if ( length <= 0 ) continue ;
402404
403- var data = new byte [ length ] ;
405+ var data = ArrayPool < byte > . Shared . Rent ( length ) ;
404406
405407 readBytes = 0 ;
406408
@@ -414,7 +416,9 @@ private async void ReadTcp(CancellationToken cancellationToken)
414416 }
415417 while ( readBytes < length ) ;
416418
417- var message = ProtoMessage . Parser . ParseFrom ( data ) ;
419+ var message = ProtoMessage . Parser . ParseFrom ( data , 0 , length ) ;
420+
421+ ArrayPool < byte > . Shared . Return ( data ) ;
418422
419423 OnNext ( message ) ;
420424 }
You can’t perform that action at this time.
0 commit comments