/// <summary> /// GET for establishing the downchannel using the directives path /// Refer /// </summary> public async void CreateDownchannel() { using (System.Net.Http.HttpClient get = new System.Net.Http.HttpClient()) { get.DefaultRequestHeaders.Add("Authorization", "Bearer " + Ini.access_token); var response = await(get.GetAsync(directivesURL, System.Net.Http.HttpCompletionOption.ResponseHeadersRead)); var stream = await response.Content.ReadAsStreamAsync(); var buffer = new byte[2048]; while (await stream.ReadAsync(buffer, 0, buffer.Length) > 0) { // Report progress and write to a different stream string directive = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length); using (StringReader reader = new StringReader(directive)) { string line; while ((line = reader.ReadLine()) != null) { if (line.Contains("{\"directive\":{\"")) { Directives.ParseDirective(line); } } } Array.Clear(buffer, 0, buffer.Length); } } }