Reset timeout on websocket send and publishes
This commit is contained in:
@@ -55,6 +55,12 @@ public:
|
||||
|
||||
/* Send or buffer a WebSocket frame, compressed or not. Returns false on increased user space backpressure. */
|
||||
bool send(std::string_view message, uWS::OpCode opCode = uWS::OpCode::BINARY, bool compress = false) {
|
||||
/* Every send resets the timeout */
|
||||
WebSocketContextData<SSL> *webSocketContextData = (WebSocketContextData<SSL> *) us_socket_context_ext(SSL,
|
||||
(us_socket_context_t *) us_socket_context(SSL, (us_socket_t *) this)
|
||||
);
|
||||
AsyncSocket<SSL>::timeout(webSocketContextData->idleTimeout);
|
||||
|
||||
/* Transform the message to compressed domain if requested */
|
||||
if (compress) {
|
||||
WebSocketData *webSocketData = (WebSocketData *) Super::getAsyncSocketData();
|
||||
|
||||
@@ -47,10 +47,11 @@ struct WebSocketContextData {
|
||||
/* Each websocket context has a topic tree for pub/sub */
|
||||
TopicTree topicTree;
|
||||
|
||||
WebSocketContextData() : topicTree([](Subscriber *s, std::string_view data) -> int {
|
||||
WebSocketContextData() : topicTree([this](Subscriber *s, std::string_view data) -> int {
|
||||
/* We rely on writing to regular asyncSockets */
|
||||
auto *asyncSocket = (AsyncSocket<SSL> *) s->user;
|
||||
|
||||
asyncSocket->timeout(this->idleTimeout);
|
||||
asyncSocket->write(data.data(), data.length());
|
||||
|
||||
/* Reserved, unused */
|
||||
|
||||
Reference in New Issue
Block a user