From f2a5d957265542c1356e0f6f83f79170af38607c Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Tue, 22 Jan 2019 18:50:37 +0100 Subject: [PATCH] Wrap idleTimeout --- examples/WebSockets.js | 3 +++ src/AppWrapper.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/examples/WebSockets.js b/examples/WebSockets.js index 889b0eb..a758497 100644 --- a/examples/WebSockets.js +++ b/examples/WebSockets.js @@ -11,6 +11,7 @@ const app = uWS./*SSL*/App({ /* Options */ compression: 0, maxPayloadLength: 16 * 1024 * 1024, + idleTimeout: 10, /* Handlers */ open: (ws, req) => { console.log('A WebSocket connected via URL: ' + req.getUrl() + '!'); @@ -25,6 +26,8 @@ const app = uWS./*SSL*/App({ close: (ws, code, message) => { console.log('WebSocket closed'); } +}).any('/*', (res, req) => { + res.end('Nothing to see here!'); }).listen(port, (token) => { if (token) { console.log('Listening to port ' + port); diff --git a/src/AppWrapper.h b/src/AppWrapper.h index a61ac13..f3ba3e8 100644 --- a/src/AppWrapper.h +++ b/src/AppWrapper.h @@ -32,6 +32,9 @@ void uWS_App_ws(const FunctionCallbackInfo &args) { /* maxPayloadLength */ behavior.maxPayloadLength = behaviorObject->Get(String::NewFromUtf8(isolate, "maxPayloadLength"))->Int32Value(); + /* idleTimeout */ + behavior.idleTimeout = behaviorObject->Get(String::NewFromUtf8(isolate, "idleTimeout"))->Int32Value(); + /* Compression, map from 0, 1, 2 to disabled, shared, dedicated */ int compression = behaviorObject->Get(String::NewFromUtf8(isolate, "compression"))->Int32Value(); if (compression == 0) {