6 Commits

Author SHA1 Message Date
cd2354c34f Updated changelog and package.json for release 2019-03-26 20:56:30 -05:00
25188ddce9 To be safe, only pass the chunk of the buffer that's relevant 2019-03-26 19:16:23 -05:00
d70bc88f7c Actually fixed large message handling
We shouldn't be trying to read the message length out of the middle of a message when there are multiple segments.

Fixes https://github.com/parnic/node-screenlogic/issues/5 (for real this time, I hope...I don't have a way to test)
2019-03-26 07:10:18 -05:00
08c5457f2c Fixed handling of messages larger than 1024 bytes
Fixes https://github.com/parnic/node-screenlogic/issues/5
2019-03-25 20:02:58 -05:00
398a687cc6 Well that was obviously the wrong date 2019-02-23 10:23:05 -06:00
8727d53440 Revved for NPM 2019-02-22 18:58:10 -06:00
3 changed files with 25 additions and 3 deletions

View File

@ -4,7 +4,11 @@ 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.2.0 - 2017-06-20
## v1.2.1 - 2019-03-26
### Fixed
* Messages larger than 1024 bytes are now handled properly.
## v1.2.0 - 2019-02-22
### Added
* Remote connection through Pentair servers
* Connecting to password-protected systems (this is only enforced by the ScreenLogic system on remote connections)

View File

@ -124,8 +124,26 @@ class UnitConnection extends EventEmitter {
this.password = password;
this.client = new net.Socket();
var _this = this;
var buffer = Buffer.alloc(1024);
var bufferIdx = 0;
var expectedMsgLen = 0;
this.client.on('data', function(msg) {
_this.onClientMessage(msg);
if (buffer.length < msg.length + bufferIdx) {
buffer = Buffer.alloc(msg.length + buffer.length, buffer);
}
if (bufferIdx === 0) {
expectedMsgLen = msg.readInt32LE(4) + 8;
}
msg.copy(buffer, bufferIdx);
bufferIdx = bufferIdx + msg.length;
if (bufferIdx === expectedMsgLen) {
_this.onClientMessage(buffer.slice(0, expectedMsgLen));
bufferIdx = 0;
}
}).on('close', function(had_error) {
// console.log('unit connection closed');
});

View File

@ -1,7 +1,7 @@
{
"name": "node-screenlogic",
"description": "Tool for connecting to Pentair ScreenLogic systems on the local network",
"version": "1.1.0",
"version": "1.2.1",
"main": "index.js",
"license": "MIT",
"repository": "https://github.com/parnic/node-screenlogic.git",