Add server sent events, change vfs structure, dark mode error pages and dark mode anonydrop
This commit is contained in:
@@ -67,7 +67,7 @@ namespace Tesses::Framework
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer();
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer(std::function<void()> cb, int64_t interval=1000, bool enabled=true);
|
||||
std::shared_ptr<TF_Timer_Handle> TF_Timer(std::function<void()> cb, std::chrono::milliseconds interval, bool enabled=true);
|
||||
|
||||
|
||||
void TF_Init();
|
||||
void TF_InitWithConsole();
|
||||
void TF_AllowPortable(std::string argv0);
|
||||
@@ -76,6 +76,7 @@ namespace Tesses::Framework
|
||||
void TF_RunEventLoop();
|
||||
void TF_RunEventLoopItteration();
|
||||
bool TF_IsRunning();
|
||||
void TF_Sleep(uint32_t sleepMS);
|
||||
void TF_SetIsRunning(bool _isRunning);
|
||||
void TF_Quit();
|
||||
bool TF_GetConsoleEventsEnabled();
|
||||
|
||||
@@ -13,12 +13,30 @@ namespace Tesses::Framework::Http
|
||||
public:
|
||||
virtual ~ServerContextData();
|
||||
};
|
||||
|
||||
class ServerContext;
|
||||
class ServerSentEvents {
|
||||
std::vector<std::shared_ptr<Tesses::Framework::Streams::Stream>> strms;
|
||||
Tesses::Framework::Threading::Mutex mtx;
|
||||
private:
|
||||
void SendEventRaw(const std::string& evt);
|
||||
public:
|
||||
void SendRetry(uint32_t ms);
|
||||
void SendRetry(std::chrono::milliseconds ms);
|
||||
void SendRetry(Tesses::Framework::Date::TimeSpan ts);
|
||||
void SendData(const std::string& message);
|
||||
void SendData(const std::string& message, const std::string& dataType);
|
||||
void SendId(const std::string& idVal);
|
||||
void SendCustomEvent(const std::string& type, const std::string& value);
|
||||
void SendComment(const std::string& comment);
|
||||
friend class ServerContext;
|
||||
};
|
||||
|
||||
|
||||
class ServerContext {
|
||||
|
||||
bool sent;
|
||||
bool debug;
|
||||
std::vector<std::shared_ptr<ServerSentEvents>> sse;
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> strm;
|
||||
std::map<std::string,ServerContextData*> data;
|
||||
std::queue<std::function<bool(ServerContext& ctx)>> headerhandlers;
|
||||
@@ -54,6 +72,7 @@ namespace Tesses::Framework::Http
|
||||
void SendNotFound();
|
||||
void SendBadRequest();
|
||||
void SendException(std::exception& ex);
|
||||
void SendServerSentEvents(std::shared_ptr<ServerSentEvents> sse);
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenResponseStream();
|
||||
std::shared_ptr<Tesses::Framework::Streams::Stream> OpenRequestStream();
|
||||
ServerContext& WithStatusCode(StatusCode code);
|
||||
@@ -87,6 +106,9 @@ namespace Tesses::Framework::Http
|
||||
data[name] = item;
|
||||
return item;
|
||||
}
|
||||
friend class ServerSentEvents;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class IHttpServer {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
namespace Tesses::Framework::Streams
|
||||
{
|
||||
class NetworkStream;
|
||||
|
||||
|
||||
class TcpServer {
|
||||
int32_t sock;
|
||||
bool owns;
|
||||
@@ -20,7 +20,7 @@ namespace Tesses::Framework::Streams
|
||||
~TcpServer();
|
||||
bool IsValid();
|
||||
void Close();
|
||||
};
|
||||
};
|
||||
enum class SocketType {
|
||||
ST_IPv4_TCP,
|
||||
ST_IPv4_UDP,
|
||||
@@ -46,14 +46,19 @@ namespace Tesses::Framework::Streams
|
||||
void Listen(int32_t backlog);
|
||||
void Bind(std::string ip, uint16_t port);
|
||||
void SetBroadcast(bool bC);
|
||||
void SetReuseAddress(bool reuse);
|
||||
void SetReusePort(bool reuse);
|
||||
void SetMulticastTTL(uint8_t ttl);
|
||||
void SetMulticastMembership(std::string multicastAddress, std::string ifaceIP="0.0.0.0");
|
||||
std::shared_ptr<NetworkStream> Accept(std::string& ip, uint16_t& port);
|
||||
size_t Read(uint8_t* buff, size_t sz);
|
||||
size_t Write(const uint8_t* buff, size_t sz);
|
||||
size_t ReadFrom(uint8_t* buff, size_t sz, std::string& ip, uint16_t& port);
|
||||
size_t WriteTo(const uint8_t* buff, size_t sz, std::string ip, uint16_t port);
|
||||
static std::vector<std::pair<std::string,std::string>> GetIPs(bool ipV6=false);
|
||||
|
||||
~NetworkStream();
|
||||
void SetNoDelay(bool noDelay);
|
||||
void Close();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user