Ignore:
Timestamp:
Jul 23, 2024, 6:49:56 PM (4 months ago)
Author:
alloc
Message:

*Fixed: Chat code
*Fixed: SSE connection counting, added connection set up logging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TFP-WebServer/WebServer/src/SSE/SseClient.cs

    r487 r499  
    11using System;
    22using System.IO;
     3using System.Net;
    34using System.Net.Sockets;
    45using System.Text;
    5 using SpaceWizards.HttpListener;
    66using Webserver.UrlHandlers;
     7using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
    78
    89namespace Webserver.SSE {
     
    1718        private static readonly byte[] keepAliveData = Encoding.UTF8.GetBytes (": KeepAlive\n\n");
    1819
     20        public readonly IPEndPoint RemoteEndpoint;
    1921        private readonly SseHandler parent;
    2022        private readonly HttpListenerResponse response;
    2123        private DateTime lastMessageSent = DateTime.Now;
    2224
    23         public SseClient (SseHandler _parent, HttpListenerResponse _response) {
     25        public SseClient (SseHandler _parent, RequestContext _context) {
    2426            parent = _parent;
    25             response = _response;
     27            response = _context.Response;
     28            RemoteEndpoint = _context.Request.RemoteEndPoint;
    2629           
    2730            // Keep the request open
    28             _response.SendChunked = true;
     31            response.SendChunked = true;
    2932
    30             _response.AddHeader ("Content-Type", "text/event-stream");
    31             _response.OutputStream.Flush ();
     33            response.AddHeader ("Content-Type", "text/event-stream");
     34            response.OutputStream.Flush ();
    3235        }
    3336
Note: See TracChangeset for help on using the changeset viewer.