commit 11e0482d04fc27749e16526555278b9a01d2b416 Author: Alex Hultman Date: Sun May 6 16:43:26 2018 +0200 Set up projects diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d6e93f4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "uSockets"] + path = uSockets + url = https://github.com/uNetworking/uSockets.git diff --git a/15.pro b/15.pro new file mode 100644 index 0000000..371b6da --- /dev/null +++ b/15.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +CONFIG += console c++14 +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += \ + main.cpp \ + uSockets/src/context.c \ + uSockets/src/libusockets.c \ + uSockets/src/socket.c \ + uSockets/src/backends/epoll.c \ + uSockets/src/backends/libuv.c + +INCLUDEPATH += uSockets/src +QMAKE_CXXFLAGS += -std=c++14 diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..710ff6b --- /dev/null +++ b/main.cpp @@ -0,0 +1,59 @@ +#include "libusockets.h" + +#include +#include +using namespace std; + +struct HttpRequest { + +}; + +struct HttpResponse { + + void write() { + + } + +}; + +struct Hub { + us_loop *loop; + + static void wakeup_cb(us_loop *loop) { + + } + + struct Data { + std::function onHttpRequest; + } *data; + + void onHttpRequest(decltype(Data::onHttpRequest) handler) { + data->onHttpRequest = handler; + } + + Hub() { + loop = us_create_loop(wakeup_cb, sizeof(Data)); + data = (Data *) us_loop_userdata(loop); + } + + ~Hub() { + // us_loop_delete(loop); + } +}; + +int main() { + + Hub h; + + h.onHttpRequest([](auto req, auto res) { + + // res.writeStatus(); + // res.writeHeader(); + // res.write(); + + res->write(); + + }); + + +} diff --git a/uSockets b/uSockets new file mode 160000 index 0000000..146ef52 --- /dev/null +++ b/uSockets @@ -0,0 +1 @@ +Subproject commit 146ef525667b653fe7fab7d66d623c32abc481d1