Add changeable server

This commit is contained in:
2025-10-14 23:12:43 -05:00
parent 1a419d9575
commit 931cf49320
13 changed files with 139 additions and 13 deletions

View File

@@ -43,7 +43,10 @@ namespace Tesses::Framework
mtx.Lock();
for(std::shared_ptr<Event<TArgs...>>& item : this->items)
{
if(item.get() == event.get()) return;
if(item.get() == event.get()) {
mtx.Unlock();
return;
}
}
this->items.push_back(event);
mtx.Unlock();
@@ -56,10 +59,11 @@ namespace Tesses::Framework
if(i->get() == event.get())
{
this->items.erase(i);
mtx.Unlock();
return;
}
}
mtx.Lock();
mtx.Unlock();
}
void Invoke(TArgs... args)
{

View File

@@ -57,6 +57,5 @@ namespace Tesses::Framework::Filesystem
void Chmod(VFSPath path, uint32_t mode);
void Close();
};
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "HttpServer.hpp"
namespace Tesses::Framework::Http
{
class ChangeableServer {
public:
ChangeableServer();
ChangeableServer(std::shared_ptr<IHttpServer> original);
std::shared_ptr<IHttpServer> server;
bool Handle(ServerContext& ctx);
~ChangeableServer();
};
}

View File

@@ -56,8 +56,15 @@ namespace Tesses::Framework::Http
ServerContext& WithMimeType(std::string mime);
ServerContext& WithContentDisposition(std::string filename, bool isInline);
ServerContext& WriteHeaders();
ServerContext& WithLocationHeader(std::string url);
ServerContext& WithLocationHeader(std::string url,StatusCode sc);
void StartWebSocketSession(std::function<void(std::function<void(WebSocketMessage&)>,std::function<void()>,std::function<void()>)> onOpen, std::function<void(WebSocketMessage&)> onReceive, std::function<void(bool)> onClose);
void StartWebSocketSession(std::shared_ptr<WebSocketConnection> connection);
std::string GetServerRoot();
std::string MakeAbsolute(std::string path);
void SendRedirect(std::string url);
void SendRedirect(std::string url, StatusCode sc);
template<class T>
T* GetServerContentData(std::string tag)

View File

@@ -24,6 +24,7 @@ namespace Tesses::Framework::Streams
virtual void Flush();
virtual void Seek(int64_t pos, SeekOrigin whence);
void CopyTo(std::shared_ptr<Stream> strm, size_t buffSize=1024);
void CopyToLimit(std::shared_ptr<Stream> strm,uint64_t len, size_t buffSize=1024);
virtual void Close();
virtual ~Stream();
};

View File

@@ -6,6 +6,7 @@
#include "Http/CallbackServer.hpp"
#include "Http/MountableServer.hpp"
#include "Http/ContentDisposition.hpp"
#include "Http/ChangeableServer.hpp"
#include "Streams/FileStream.hpp"
#include "Streams/MemoryStream.hpp"
#include "Streams/NetworkStream.hpp"