Open wanghongjuan opened 7 years ago
Now I need to receive a resource object from terminal when running command outdir/linux/release/jslinux, but I am not clear how to do it.
outdir/linux/release/jslinux
client.js
var ocf = require('ocf'); var client = ocf.client; var updateProperties = { range: [0, 255] }; console.log("Started OCF client"); function errorHandler(error) { if (error.deviceId) { console.log("Error for device: " + error.deviceId); } } client.on('error', errorHandler); function updateResource(resource, data){ resource.properties.minRange = updateProperties.range[0]; resource.properties.maxRange = updateProperties.range[1]; resource.properties.RValue = data[0]; resource.properties.GValue = data[1]; resource.properties.BValue = data[2]; console.log(resource.properties.RValue); console.log(resource.properties.GValue); console.log(resource.properties.BValue); } client.update(resource) .then( function(updateResource){ if(updateResource == resource){ console.log('updated resource'); } }, function(error){ console.log('failed to update resource with error', error.message); } ) } ocf.start(); updateResource(process.argv[2], process.argv[3])
server.js
process.argv[2/3]
Not clear how to receive the argument resource object.
The client.js can get the argument from terminal and the update method can be executed successfully.
This will probably be a new feature, like if we want to support the process api
Description
Now I need to receive a resource object from terminal when running command
outdir/linux/release/jslinux
, but I am not clear how to do it.Test Code
client.js
server.js
process.argv[2/3]
is a hypothetical value.Steps to reproduce
Actual Result
Not clear how to receive the argument resource object.
Excepted Result
The client.js can get the argument from terminal and the update method can be executed successfully.