Set up projects
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "uSockets"]
|
||||||
|
path = uSockets
|
||||||
|
url = https://github.com/uNetworking/uSockets.git
|
||||||
@@ -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
|
||||||
@@ -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
Reference in New Issue
Block a user