mirror of
https://onedev.site.tesses.net/tesses-framework
synced 2026-02-08 15:55:46 +00:00
Add changeable server
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,5 @@ namespace Tesses::Framework::Filesystem
|
||||
|
||||
void Chmod(VFSPath path, uint32_t mode);
|
||||
|
||||
void Close();
|
||||
};
|
||||
}
|
||||
14
include/TessesFramework/Http/ChangeableServer.hpp
Normal file
14
include/TessesFramework/Http/ChangeableServer.hpp
Normal 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();
|
||||
};
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user