Skip to content

Commit

Permalink
Add close events to each class
Browse files Browse the repository at this point in the history
  • Loading branch information
parnic committed May 20, 2022
1 parent b2774e4 commit f173c2b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.9.1 - 2022-05-20

### Added

* Added `close` event to FindUnits, RemoteLogin, and UnitConnection for when the connection to the endpoint has closed.

## v1.9.0 - 2022-05-20

### Added
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ Closes the socket.

#### Events

* `close` - Indicates that `close()` has been called on the finder.
* `error` - Indicates that an unhandled error was caught.
* `serverFound` - Indicates that a ScreenLogic unit has been found. Event handler receives a [`UnitConnection`](#unitconnection) object.

Examples:
Expand Down Expand Up @@ -162,8 +164,9 @@ Closes the connection

#### Events

* `close` - Indicates that the connection to the remote login server has been closed. Event handler receives a bool indicating whether there was a transmission error.
* `error` - Indicates that an unhandled error was caught (such as the connection timing out).
* `gatewayFound` - Indicates that the search for the named unit has completed (may or may not be successful). Event handler receives a [`SLGetGatewayDataMessage`](#slgetgatewaydatamessage) argument.
* `error` - Indicates that an unhandled error was caught (such as the connection timing out)

### UnitConnection

Expand Down Expand Up @@ -318,6 +321,7 @@ Sets the current date and time of the ScreenLogic system. Emits the `setSystemTi
* `cancelDelay` - Indicates that a response to `cancelDelay()` has been received. Event handler receives a [`SLCancelDelay`](#slcanceldelay) object.
* `chemicalData` - Indicates that a response to `getChemicalData()` has been received. Event handler receives a [`SLChemDataMessage`](#slchemdatamessage) object.
* `circuitStateChanged` - Indicates that a response to `setCircuitState()` has been received. Event handler receives a [`SLSetCircuitStateMessage`](#slsetcircuitstatemessage) object.
* `close` - Indicates that the connection to the unit has been closed. Event handler receives a bool indicating whether there was a transmission error.
* `controllerConfig` - Indicates that a response to `getControllerConfig()` has been received. Event handler receives a [`SLControllerConfigMessage`](#slcontrollerconfigmessage) object.
* `deleteScheduleById` - Indicates that a response to `deleteScheduleById()` has been received. Event handler receives a [`SLDeleteScheduleEventById`](#sldeletescheduleeventbyid) object.
* `error` - Indicates that an unhandled error was caught (such as the connection timing out)
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class FindUnits extends EventEmitter {
_this.foundServer(message, remote);
}).on('close', function() {
debugFind('closed');
_this.emit('close');
}).on('error', function(e) {
debugFind('error: %O', e);
_this.emit('error', e);
Expand Down Expand Up @@ -77,6 +78,7 @@ class RemoteLogin extends EventEmitter {
_this.onClientMessage(msg);
}).on('close', function(had_error) {
debugRemote('remote login server connection closed');
_this.emit('close', had_error);
}).on('error', function(e) {
debugRemote('error: %o', e);
_this.emit('error', e);
Expand Down Expand Up @@ -157,6 +159,7 @@ class UnitConnection extends EventEmitter {
}
}).on('close', function(had_error) {
debugUnit('closed');
_this.emit('close', had_error);
}).on('error', function(e) {
debugUnit('error: %o', e);
_this.emit('error', e);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "node-screenlogic",
"description": "Tool for connecting to Pentair ScreenLogic systems on the local network",
"version": "1.9.0",
"version": "1.9.1",
"main": "index.js",
"license": "MIT",
"repository": "https://github.com/parnic/node-screenlogic.git",
Expand Down

0 comments on commit f173c2b

Please sign in to comment.