1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-09-24 12:56:42 +00:00

Implement websocket communication with kj-http

Now that capnp/kj provides http and websocket functions, replace
the excellent websocketpp library with the kj functions. This
removes a dependency and allows for more consistent idiomatic
code. Thanks websocketpp, it was great to have you along!

This should enable parts of the refactor described in #49
This commit is contained in:
Oliver Giles
2018-06-30 20:34:56 +03:00
parent 0b15939f90
commit 4c2aa2680f
7 changed files with 154 additions and 227 deletions

View File

@@ -20,6 +20,7 @@
#define LAMINAR_SERVER_H_
#include <kj/async-io.h>
#include <kj/compat/http.h>
#include <capnp/message.h>
#include <capnp/capability.h>
#include <functional>
@@ -50,21 +51,19 @@ public:
void addWatchPath(const char* dpath);
private:
kj::Promise<void> acceptHttpClient(kj::Own<kj::ConnectionReceiver>&& listener);
kj::Promise<void> acceptRpcClient(kj::Own<kj::ConnectionReceiver>&& listener);
kj::Promise<void> handleFdRead(kj::AsyncInputStream* stream, char* buffer, std::function<void(const char*,size_t)> cb);
void taskFailed(kj::Exception&& exception) override;
private:
struct WebsocketConnection;
class HttpImpl;
int efd_quit;
capnp::Capability::Client rpcInterface;
LaminarInterface& laminarInterface;
kj::Own<HttpImpl> httpInterface;
kj::AsyncIoContext ioContext;
kj::HttpHeaderTable headerTable;
kj::Own<kj::HttpService> httpService;
kj::Own<kj::HttpServer> httpServer;
kj::Own<kj::TaskSet> listeners;
kj::TaskSet childTasks;
kj::TaskSet httpConnections;