Fix SSE Maybe
This commit is contained in:
parent
9570287c11
commit
969b4719bd
18
Program.cs
18
Program.cs
|
@ -20,8 +20,8 @@ namespace youtube_downloader
|
|||
public class SSE
|
||||
{
|
||||
public static SSE ServerSentEventItem = new SSE();
|
||||
List<StreamWriter> Streams = new List<StreamWriter>();
|
||||
public void RegisterStreamWriter(StreamWriter rp)
|
||||
List<HttpListenerResponse> Streams = new List<HttpListenerResponse>();
|
||||
public void RegisterStreamWriter(HttpListenerResponse rp)
|
||||
{
|
||||
Streams.Add(rp);
|
||||
}
|
||||
|
@ -40,11 +40,9 @@ namespace youtube_downloader
|
|||
{
|
||||
try
|
||||
{
|
||||
if(items.BaseStream != null)
|
||||
{
|
||||
items.Write(raw_data);
|
||||
items.Write("\n\n");
|
||||
}
|
||||
var bytes = Encoding.UTF8.GetBytes(raw_data + "\n\n");
|
||||
await items.OutputStream.WriteAsync(bytes, 0, bytes.Length);
|
||||
await items.OutputStream.FlushAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -309,8 +307,10 @@ namespace youtube_downloader
|
|||
{
|
||||
rp.AddHeader("Cache-Control", "no-cache");
|
||||
rp.ContentType = "text/event-stream";
|
||||
StreamWriter w = new StreamWriter(rp.OutputStream, rp.ContentEncoding);
|
||||
SSE.ServerSentEventItem.RegisterStreamWriter(w);
|
||||
rp.WithCode();
|
||||
rp.ContentEncoding = Encoding.UTF8;
|
||||
|
||||
SSE.ServerSentEventItem.RegisterResponse(rp);
|
||||
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue