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

Commit

Permalink
Merge pull request #10 from Alethio/v1.5.1
Browse files Browse the repository at this point in the history
V1.5.1
  • Loading branch information
baxy authored May 22, 2019
2 parents 0846faa + 29a9c61 commit b9b66d9
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 62 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.5.1] - 2019-05-22
- Add "clientTimeout" message sent to the client when inactive for more then 3 minutes

## [1.5.0] - 2019-05-21
- Add WebSocket API improvements
- Add WebSocket API documentation
Expand Down
11 changes: 9 additions & 2 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,15 @@ export default class Server {
let lastActivityTimestamp = this.session.getVar(sparkId, 'lastActivityTimestamp');

if (lastPingTimestamp - lastActivityTimestamp >= (this.wsTimeout * 1000)) {
this.log.info(`[${sparkId}] - No response from client for more than ${this.wsTimeout} seconds, ending connection`);
this.clients[sparkId].end();
let notificationMessage = `No data received for more than ${this.wsTimeout} seconds, ending connection`;

this.log.info(`[${sparkId}] - ${notificationMessage}`);

let responseObject = this.lodash.cloneDeep(this.controllers.AbstractController.responseObject);
responseObject.success = false;
responseObject.errors.push(notificationMessage);
this.controllers.AbstractController.clientWrite(this.clients[sparkId], 'clientTimeout', responseObject);
this.controllers.AbstractController.clientClose(this.clients[sparkId]);
}

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

0 comments on commit b9b66d9

Please sign in to comment.