The development of C# v3 is currently in progress. We will provide an update once it is completed.
In the meantime, you may refer to the following folder, which contains the compiled proto files and an example class to connect to the v3 WebSocket: GitHub Link
We have applied additional changes to parse & read Socket response in SDK project.
@Ketan_Gupta , Please advise if this looks good Or any other changes required.
\Feeder\MarketDataFeeder.cs
private async Task ReceiveMessagesAsync()
{
var buffer = new byte[4096];
using (var messageStream = new System.IO.MemoryStream()) // For accumulating message fragments
{
try
{
while (WebSocket.State == WebSocketState.Open)
{
var resultSegment = new ArraySegment<byte>(buffer);
var result = await WebSocket.ReceiveAsync(resultSegment, CancellationToken.None);
if (result.MessageType == WebSocketMessageType.Binary)
{
//RaiseOnBinaryMessageEvent(buffer, result);
// Add the received fragment to our message stream
messageStream.Write(buffer, 0, result.Count);
// Only process when we have the complete message
if (result.EndOfMessage)
{
byte[] completeMessage = messageStream.ToArray();
// Create a new result that represents the complete message
var completeResult = new WebSocketReceiveResult(
(int)messageStream.Length,
WebSocketMessageType.Binary,
true);
// Process the complete message
RaiseOnBinaryMessageEvent(completeMessage, completeResult);
// Reset for next message
messageStream.SetLength(0);
messageStream.Position = 0;
}
// If not end of message, continue receiving fragments
}
else if (result.MessageType == WebSocketMessageType.Close)
{
int closeStatusCode = (int)WebSocket.CloseStatus.Value;
string closeStatusDescription = WebSocket.CloseStatusDescription;
RaiseOnCloseEvent(closeStatusCode, closeStatusDescription);
await WebSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None);
break;
}
}
}
catch (Exception ex)
{
RaiseOnErrorEvent(ex);
}
}
}