2019-05-05 00:11:57 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-05-11 22:27:33 -07:00
|
|
|
#include <set>
|
2019-05-11 21:53:12 -07:00
|
|
|
|
2019-05-07 23:44:55 -07:00
|
|
|
#include "firecgi/server.h"
|
2019-05-05 00:11:57 -07:00
|
|
|
#include "stream.h"
|
|
|
|
|
|
|
|
|
|
namespace firesse {
|
|
|
|
|
|
|
|
|
|
class Server {
|
|
|
|
|
public:
|
2019-05-11 21:53:12 -07:00
|
|
|
Server(int port, const std::function<void(Stream*)>& callback);
|
2019-05-05 00:11:57 -07:00
|
|
|
void Serve();
|
2019-05-11 21:53:12 -07:00
|
|
|
void Shutdown();
|
|
|
|
|
void RegisterSignalHandlers();
|
2019-05-05 00:11:57 -07:00
|
|
|
|
|
|
|
|
private:
|
2019-05-07 23:26:48 -07:00
|
|
|
void OnRequest(firecgi::Request* request);
|
2019-05-05 00:11:57 -07:00
|
|
|
|
2019-05-11 21:53:12 -07:00
|
|
|
std::function<void(Stream*)> callback_;
|
2019-05-05 00:11:57 -07:00
|
|
|
firecgi::Server firecgi_server_;
|
2019-05-11 22:27:33 -07:00
|
|
|
|
|
|
|
|
std::mutex mu_;
|
|
|
|
|
std::set<Stream*, IsFresherStream> streams_;
|
2019-05-05 00:11:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace firesse
|