Hook up AsyncSocket with WebSocket

This commit is contained in:
Alex Hultman
2018-10-30 03:26:43 +01:00
parent f2e2b7107a
commit 57255c874d
4 changed files with 24 additions and 7 deletions
+10
View File
@@ -9,6 +9,8 @@
#include "WebSocketData.h"
#include "AsyncSocket.h"
namespace uWS {
template <bool SSL>
@@ -75,12 +77,20 @@ private:
/* Handle HTTP data streams */
static_dispatch(us_ssl_socket_context_on_data, us_socket_context_on_data)(getSocketContext(), [](auto *s, char *data, int length) {
AsyncSocket<SSL> *webSocket = (AsyncSocket<SSL> *) s;
webSocket->cork();
// get the data
WebSocketData *wsState = (WebSocketData *) us_socket_ext(s);
// this parser requires almost no time -> 215k req/sec of 215k possible
uWS::WebSocketProtocol<true, WebSocketProtcolImplementation<true>>::consume(data, length, wsState, s);
webSocket->uncork();
return s;
});