I have the following code:
Console.WriteLine("New Socket connection opened");
var buffer = new byte[1024 * 4];
WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
while (!result.CloseStatus.HasValue)
{
Console.WriteLine("New message received : "+ Encoding.UTF8.GetString(buffer));
}
When I send Hello my client, I can see Hello????????????? on the console. Clearly, it means I have a buffer of size 1024 * 4, of which, the first few bytes are taken by Hello. How do I trim my String (eventually, I wanto pass JSON from my client to the server).