Set up projects

This commit is contained in:
Alex Hultman
2018-05-06 16:43:26 +02:00
commit 11e0482d04
4 changed files with 78 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
[submodule "uSockets"]
path = uSockets
url = https://github.com/uNetworking/uSockets.git
+15
View File
@@ -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
+59
View File
@@ -0,0 +1,59 @@
#include "libusockets.h"
#include <iostream>
#include <functional>
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<void(HttpRequest *, HttpResponse *)> 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();
});
}
Submodule
+1
Submodule uSockets added at 146ef52566