3 Commits

Author SHA1 Message Date
b8cf9a1801 Increased version for release 2018-03-31 16:27:11 -05:00
a25b0ff3b2 Added example of direct connection 2018-03-31 11:24:47 -05:00
7907430e95 Added ability to connect by address and port 2018-03-31 11:24:37 -05:00
4 changed files with 28 additions and 8 deletions

View File

@ -91,6 +91,15 @@ finder.on('serverFound', function(server) {
})
```
### constructor(port, address)
Port is an integer. Address is an IPv4 address of the server as a string.
Examples:
```javascript
var client = new ScreenLogic.UnitConnection(80, '10.0.0.85')
```
### connect()
Connects to the server passed to its constructor.

View File

@ -2,7 +2,14 @@ const ScreenLogic = require('./index');
var finder = new ScreenLogic.FindUnits();
finder.on('serverFound', function(server) {
var client = new ScreenLogic.UnitConnection(server);
connect(new ScreenLogic.UnitConnection(server));
});
finder.search();
//connect(new ScreenLogic.UnitConnection(80, '10.0.0.85'));
function connect(client) {
client.on('loggedIn', function() {
this.getVersion();
this.getPoolStatus();
@ -32,6 +39,4 @@ finder.on('serverFound', function(server) {
});
client.connect();
});
finder.search();
}

View File

@ -56,9 +56,15 @@ class FindUnits extends EventEmitter {
}
class UnitConnection extends EventEmitter {
constructor(server) {
constructor(server, address) {
super();
this.server = server;
if (typeof server === 'object') {
this.serverPort = server.port;
this.serverAddress = server.address;
} else {
this.serverPort = server;
this.serverAddress = address;
}
this.client = new net.Socket();
var _this = this;
@ -76,7 +82,7 @@ class UnitConnection extends EventEmitter {
connect() {
//console.log("connecting...");
var _this = this;
this.client.connect(this.server.port, this.server.address, function() {
this.client.connect(this.serverPort, this.serverAddress, function() {
_this.onConnected();
});
}

View File

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