I m using websocket in my windows store app. I use the same code like was in sample Connecting with WebSockets sample (Windows 8). But now I have big problem. I get bytes in readBuffer but server sending bytes in some cycles for example message have 20000 bytes then server send 1000 bytes then again 1000 bytes ..=20000. But problem is while(true) because its stil read bytes and in bytesReceived I get 20000 what is ok but readbuffer after this contain only for example 3000bytes. How I can join bytes array or how I can get result byte array. Second problem is I dont know how big will be message thats means if I try get one array this this array contains on end zeros because byte array is declared for bigger size like is in real.
private async void Scenario2ReceiveData(object state)
{
int bytesReceived = 0;
try
{
Stream readStream = (Stream)state;
MarshalText(OutputField, "Background read starting.\r\n");
while (true) // Until closed and ReadAsync fails.
{
int read = await readStream.ReadAsync(readBuffer, 0, readBuffer.Length);
bytesReceived += read;
}
}...