Add resetIdleTimeoutOnSend
This commit is contained in:
@@ -140,6 +140,7 @@ public:
|
|||||||
unsigned int idleTimeout = 120;
|
unsigned int idleTimeout = 120;
|
||||||
unsigned int maxBackpressure = 1 * 1024 * 1024;
|
unsigned int maxBackpressure = 1 * 1024 * 1024;
|
||||||
bool closeOnBackpressureLimit = false;
|
bool closeOnBackpressureLimit = false;
|
||||||
|
bool resetIdleTimeoutOnSend = true;
|
||||||
fu2::unique_function<void(HttpResponse<SSL> *, HttpRequest *, struct us_socket_context_t *)> upgrade = nullptr;
|
fu2::unique_function<void(HttpResponse<SSL> *, HttpRequest *, struct us_socket_context_t *)> upgrade = nullptr;
|
||||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *)> open = nullptr;
|
fu2::unique_function<void(uWS::WebSocket<SSL, true> *)> open = nullptr;
|
||||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *, std::string_view, uWS::OpCode)> message = nullptr;
|
fu2::unique_function<void(uWS::WebSocket<SSL, true> *, std::string_view, uWS::OpCode)> message = nullptr;
|
||||||
@@ -202,6 +203,7 @@ public:
|
|||||||
webSocketContext->getExt()->idleTimeout = behavior.idleTimeout;
|
webSocketContext->getExt()->idleTimeout = behavior.idleTimeout;
|
||||||
webSocketContext->getExt()->maxBackpressure = behavior.maxBackpressure;
|
webSocketContext->getExt()->maxBackpressure = behavior.maxBackpressure;
|
||||||
webSocketContext->getExt()->closeOnBackpressureLimit = behavior.closeOnBackpressureLimit;
|
webSocketContext->getExt()->closeOnBackpressureLimit = behavior.closeOnBackpressureLimit;
|
||||||
|
webSocketContext->getExt()->resetIdleTimeoutOnSend = behavior.resetIdleTimeoutOnSend;
|
||||||
webSocketContext->getExt()->compression = behavior.compression;
|
webSocketContext->getExt()->compression = behavior.compression;
|
||||||
|
|
||||||
httpContext->onHttp("get", pattern, [webSocketContext, behavior = std::move(behavior)](auto *res, auto *req) mutable {
|
httpContext->onHttp("get", pattern, [webSocketContext, behavior = std::move(behavior)](auto *res, auto *req) mutable {
|
||||||
|
|||||||
+3
-1
@@ -122,7 +122,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Every successful send resets the timeout */
|
/* Every successful send resets the timeout */
|
||||||
Super::timeout(webSocketContextData->idleTimeout);
|
if (webSocketContextData->resetIdleTimeoutOnSend) {
|
||||||
|
Super::timeout(webSocketContextData->idleTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
/* There needs to be a maxBackpressure which will force close everything over that limit */
|
/* There needs to be a maxBackpressure which will force close everything over that limit */
|
||||||
size_t maxBackpressure = 0;
|
size_t maxBackpressure = 0;
|
||||||
bool closeOnBackpressureLimit;
|
bool closeOnBackpressureLimit;
|
||||||
|
bool resetIdleTimeoutOnSend;
|
||||||
|
|
||||||
/* Each websocket context has a topic tree for pub/sub */
|
/* Each websocket context has a topic tree for pub/sub */
|
||||||
TopicTree topicTree;
|
TopicTree topicTree;
|
||||||
@@ -134,7 +135,9 @@ public:
|
|||||||
/* Note: this assumes we are not corked, as corking will swallow things and fail later on */
|
/* Note: this assumes we are not corked, as corking will swallow things and fail later on */
|
||||||
auto [written, failed] = asyncSocket->write(selectedData.data(), (int) selectedData.length());
|
auto [written, failed] = asyncSocket->write(selectedData.data(), (int) selectedData.length());
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
asyncSocket->timeout(this->idleTimeout);
|
if (this->resetIdleTimeoutOnSend) {
|
||||||
|
asyncSocket->timeout(this->idleTimeout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Failing here must not immediately close the socket, as that could result in stack overflow,
|
/* Failing here must not immediately close the socket, as that could result in stack overflow,
|
||||||
|
|||||||
Reference in New Issue
Block a user