Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
cd2354c34f
|
|||
25188ddce9
|
|||
d70bc88f7c
|
|||
08c5457f2c
|
|||
398a687cc6
|
|||
8727d53440
|
@ -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/),
|
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).
|
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
|
### Added
|
||||||
* Remote connection through Pentair servers
|
* Remote connection through Pentair servers
|
||||||
* Connecting to password-protected systems (this is only enforced by the ScreenLogic system on remote connections)
|
* Connecting to password-protected systems (this is only enforced by the ScreenLogic system on remote connections)
|
||||||
|
20
index.js
20
index.js
@ -124,8 +124,26 @@ class UnitConnection extends EventEmitter {
|
|||||||
this.password = password;
|
this.password = password;
|
||||||
this.client = new net.Socket();
|
this.client = new net.Socket();
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
var buffer = Buffer.alloc(1024);
|
||||||
|
var bufferIdx = 0;
|
||||||
|
var expectedMsgLen = 0;
|
||||||
|
|
||||||
this.client.on('data', function(msg) {
|
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) {
|
}).on('close', function(had_error) {
|
||||||
// console.log('unit connection closed');
|
// console.log('unit connection closed');
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "node-screenlogic",
|
"name": "node-screenlogic",
|
||||||
"description": "Tool for connecting to Pentair ScreenLogic systems on the local network",
|
"description": "Tool for connecting to Pentair ScreenLogic systems on the local network",
|
||||||
"version": "1.1.0",
|
"version": "1.2.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/parnic/node-screenlogic.git",
|
"repository": "https://github.com/parnic/node-screenlogic.git",
|
||||||
|
Reference in New Issue
Block a user