public async void streamGame()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "apiToken");
Debug.Log("Starting");
string json = "";
int count = 0;
using (Stream response = await client.GetStreamAsync($"https://lichess.org/api/board/game/stream/gHsBvpVYMuur"))
{
var line = new List<char>();
while (true)
{
var nextByte = response.ReadByte();
if (nextByte == -1)
{
break;
}
line.Add(Char.ConvertFromUtf32(nextByte)[0]);
if (nextByte == '\n')
{
json += string.Join("", line);
Debug.Log(json);
count++;
gameId.text = count.ToString();
line.Clear();
if (json.Length == 1)
{
continue;
}
}
}
Debug.Log(json);
Debug.Log("Finished");
}
}
public async void streamGame()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "apiToken");
Debug.Log("Starting");
string json = "";
int count = 0;
using (Stream response = await client.GetStreamAsync($"https://lichess.org/api/board/game/stream/gHsBvpVYMuur"))
{
var line = new List<char>();
while (true)
{
var nextByte = response.ReadByte();
if (nextByte == -1)
{
break;
}
line.Add(Char.ConvertFromUtf32(nextByte)[0]);
if (nextByte == '\n')
{
json += string.Join("", line);
Debug.Log(json);
count++;
gameId.text = count.ToString();
line.Clear();
if (json.Length == 1)
{
continue;
}
}
}
Debug.Log(json);
Debug.Log("Finished");
}
}