Skip to content
This repository was archived by the owner on Apr 27, 2021. It is now read-only.

Commit b9b66d9

Browse files
authored
Merge pull request #10 from Alethio/v1.5.1
V1.5.1
2 parents 0846faa + 29a9c61 commit b9b66d9

File tree

4 files changed

+92
-62
lines changed

4 files changed

+92
-62
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [1.5.1] - 2019-05-22
5+
- Add "clientTimeout" message sent to the client when inactive for more then 3 minutes
6+
47
## [1.5.0] - 2019-05-21
58
- Add WebSocket API improvements
69
- Add WebSocket API documentation

app/server.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,15 @@ export default class Server {
142142
let lastActivityTimestamp = this.session.getVar(sparkId, 'lastActivityTimestamp');
143143

144144
if (lastPingTimestamp - lastActivityTimestamp >= (this.wsTimeout * 1000)) {
145-
this.log.info(`[${sparkId}] - No response from client for more than ${this.wsTimeout} seconds, ending connection`);
146-
this.clients[sparkId].end();
145+
let notificationMessage = `No data received for more than ${this.wsTimeout} seconds, ending connection`;
146+
147+
this.log.info(`[${sparkId}] - ${notificationMessage}`);
148+
149+
let responseObject = this.lodash.cloneDeep(this.controllers.AbstractController.responseObject);
150+
responseObject.success = false;
151+
responseObject.errors.push(notificationMessage);
152+
this.controllers.AbstractController.clientWrite(this.clients[sparkId], 'clientTimeout', responseObject);
153+
this.controllers.AbstractController.clientClose(this.clients[sparkId]);
147154
}
148155

149156
if (this.clients[sparkId] !== undefined && this.session.getVar(sparkId, 'isV1Client') === false) {

0 commit comments

Comments
 (0)