Changeset 499 for TFP-WebServer/WebServer/src/SSE/SseClient.cs
- Timestamp:
- Jul 23, 2024, 6:49:56 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/SSE/SseClient.cs
r487 r499 1 1 using System; 2 2 using System.IO; 3 using System.Net; 3 4 using System.Net.Sockets; 4 5 using System.Text; 5 using SpaceWizards.HttpListener;6 6 using Webserver.UrlHandlers; 7 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse; 7 8 8 9 namespace Webserver.SSE { … … 17 18 private static readonly byte[] keepAliveData = Encoding.UTF8.GetBytes (": KeepAlive\n\n"); 18 19 20 public readonly IPEndPoint RemoteEndpoint; 19 21 private readonly SseHandler parent; 20 22 private readonly HttpListenerResponse response; 21 23 private DateTime lastMessageSent = DateTime.Now; 22 24 23 public SseClient (SseHandler _parent, HttpListenerResponse _response) {25 public SseClient (SseHandler _parent, RequestContext _context) { 24 26 parent = _parent; 25 response = _response; 27 response = _context.Response; 28 RemoteEndpoint = _context.Request.RemoteEndPoint; 26 29 27 30 // Keep the request open 28 _response.SendChunked = true;31 response.SendChunked = true; 29 32 30 _response.AddHeader ("Content-Type", "text/event-stream");31 _response.OutputStream.Flush ();33 response.AddHeader ("Content-Type", "text/event-stream"); 34 response.OutputStream.Flush (); 32 35 } 33 36
Note:
See TracChangeset
for help on using the changeset viewer.