Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Base HTTP impl
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBron committed Oct 29, 2022
1 parent 9b72e04 commit 43bbbc6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions DES-Core/DESrv.PDK/Connections/BaseHttpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,33 @@ public class BaseHttpProcessor : IConnectionProcessor<HttpListenerContext>, IDis
while (true) {
var client = AcceptConnection();
//Log.Success("Accepted HTTP connection", "DESrv TCP Processor");

var thr = new Thread(() => { Process(client); });
thr.Name = $"DESrv-PDK-HTTPProcessor-{client}";
thr.Start();
}
}

protected virtual HttpListenerContext AcceptConnection() {
return httpServer.GetContext();
var client = httpServer.GetContext();
NewClientConnectedEvent?.Invoke(client);
clients.Add(client);
return client;
}
public void Listen() => throw new NotImplementedException();
public void Listen() {
while (true) {
foreach (var c in clients) {
try {
HttpListenerRequest request = c.Request;
HttpListenerResponse response = c.Response;
response.StatusCode = (int)HttpStatusCode.NoContent;
response.ContentLength64 = 0;
response.OutputStream.Close();
} catch (Exception e) { Console.WriteLine(e.ToString()); continue; }
}
}
}

public virtual void Process(HttpListenerContext client) {
//try {
// var stream = client.GetStream();
Expand Down

0 comments on commit 43bbbc6

Please sign in to comment.