diff --git a/README.md b/README.md
index 5426886..d6a2c58 100644
--- a/README.md
+++ b/README.md
@@ -57,12 +57,13 @@ If you want to install a version of this demo in your local Lightstreamer Server
* Alternatively, you may plug the *robust* versions of the Proxy Data Adapter: go to the `deployment/Deployment_LS(robust)` folder and copy the `ChatAdapterNode` directory and all of its files into the `adapters` folder.
* Install the lightstreamer-adapter module.
* Create a directory where to deploy the Node.js Remote Adapter and let call it `Deployment_Node_Remote_Adapter`.
- * Go to the `Deployment_Node_Remote_Adapter` folder and launch the command:
+ * Go to the `Deployment_Node_Remote_Adapter` folder and launch the commands:
`> npm install lightstreamer-adapter`
+ `> npm install command-line-args`
* Download the `nodechat.js` and the `robustconnect.js` files from this project and copy them into the `Deployment_Node_Remote_Adapter` folder.
* Launch Lightstreamer Server. The Server startup will complete only after a successful connection between the Proxy Data Adapter and the Remote Data Adapter.
* Launch the Node.js Remote Adapter: go to the `Deployment_Node_Remote_Adapter` folder and launch:
-`> node nodechat.js`
+`> node nodechat.js --host localhost --metadata_rrport 8003 --data_rrport 8001 --data_notifport 8002`
* Test the Adapter, launching the [Lightstreamer - Basic Chat Demo - HTML Client](https://github.com/Lightstreamer/Lightstreamer-example-Chat-client-javascript) listed in [Clients Using This Adapter](https://github.com/Lightstreamer/Lightstreamer-example-Chat-adapter-node#clients-using-this-adapter).
* To make the [Lightstreamer - Basic Chat Demo - HTML Client](https://github.com/Lightstreamer/Lightstreamer-example-Chat-client-javascript) front-end pages get data from the newly installed Adapter Set, you need to modify the front-end pages and set the required Adapter Set name to PROXY_NODECHAT when creating the LightstreamerClient instance. So edit the `lsClient.js` file of the *Basic Chat Demo* front-end deployed under `Lightstreamer/pages/ChatDemo` and replace:
`var lsClient = new LightstreamerClient(protocolToUse+"//localhost:"+portToUse,"CHAT");`
@@ -94,5 +95,5 @@ should become like this:
## Lightstreamer Compatibility Notes
-* Compatible with Lightstreamer SDK for Node.js Adapters since 1.3
+* Compatible with Lightstreamer SDK for Node.js Adapters version 1.3 or newer
- For a version of this example compatible with Lightstreamer SDK for Node.js Adapters version 1.0, please refer to [this tag](https://github.com/Lightstreamer/Lightstreamer-example-Chat-adapter-node/tree/for_Lightstreamer_5.1).
diff --git a/nodechat.js b/nodechat.js
index 9ff7692..57e6de9 100644
--- a/nodechat.js
+++ b/nodechat.js
@@ -19,12 +19,7 @@ var
DataProvider = require('lightstreamer-adapter').DataProvider,
net = require('./robustconnect'),
inspect = require('util').inspect,
-
- // Remote proxy host and ports
- HOST = 'localhost',
- REQ_RESP_PORT = 8001,
- WRITE_PORT = 8002,
- META_PORT = 8003,
+ commandLineArgs = require('command-line-args'),
// Request/response socket channel
reqRespStream,
@@ -46,21 +41,30 @@ var
// User data just for the demo
sessions = [];
+
+ const optionDefinitions = [
+ { name: 'host', type: String },
+ { name: 'metadata_rrport', type: Number },
+ { name: 'data_rrport', type: Number },
+ { name: 'data_notifport', type: Number },
+ ];
+
+ const options = commandLineArgs(optionDefinitions);
// Create socket connections
-net.createConnection(REQ_RESP_PORT, HOST, function(stream) {
+net.createConnection(options.data_rrport, options.host, function(stream) {
reqRespStream = stream;
if(notifyStream) {
initDataProvider();
}
});
-net.createConnection(WRITE_PORT, HOST, function(stream) {
+net.createConnection(options.data_notifport, options.host, function(stream) {
notifyStream = stream;
if(reqRespStream) {
initDataProvider();
}
});
-net.createConnection(META_PORT, HOST, function(stream) {
+net.createConnection(options.metadata_rrport, options.host, function(stream) {
metadataStream = stream;
initMetadataProvider();
});
@@ -75,7 +79,7 @@ function initDataProvider() {
console.log("Subcribed item: " + itemName);
if (itemName === "chat_room") {
subscribed = true;
- response.success();
+ response.success();
} else {
response.error("No such item", "subscription");
}
diff --git a/package.json b/package.json
index b59f054..2cf0277 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lightstreamer-adapter-chat",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "Hello world application showing how to develop simple Lightstreamer adapters based on node.",
"keywords": [
"lightstreamer",
@@ -40,6 +40,7 @@
],
"dependencies": {
+ "command-line-args": "^5.0.2",
"lightstreamer-adapter": ">=1.3.0"
}
}
\ No newline at end of file