intel / iotivity-node

Node.js bindings for IoTivity
https://www.iotivity.org/
42 stars 44 forks source link

findResources() gets 4 resources even there is no OCF server running #127

Closed qiuzhong closed 7 years ago

qiuzhong commented 7 years ago

For iotivity-node-1.2.0-2, when there is no OCF server running, findResources still gets 4 resources with the href:

# curl http://127.0.0.1:8000/api/oic/res
[{"di":"35e24438-36bc-4a31-af43-de4277647713","links":[{"href":"/oic/sec/doxm","rt":"oic.r.doxm","if":"oic.if.baseline"}]},{"di":"35e24438-36bc-4a31-af43-de4277647713","links":[{"href":"/oic/sec/pstat","rt":"oic.r.pstat","if":"oic.if.baseline"}]},{"di":"35e24438-36bc-4a31-af43-de4277647713","links":[{"href":"/oic/d","rt":"oic.wk.d","if":"oic.if.baseline"}]},{"di":"35e24438-36bc-4a31-af43-de4277647713","links":[{"href":"/oic/p","rt":"oic.wk.p","if":"oic.if.baseline"}]

For iotivity-node-1.1.1-3, it will return just []

These resources can still be discovered if there are any other OCF servers running. Not sure if this change comply the spec.

gabrielschulhof commented 7 years ago

Since we no longer specify whether the stack is to run in client mode or whether it is to run in server mode, I have no choice but to start the lowlevel stack with OCInit(null, 0, OC_CLIENT_SERVER). This means that even if you just start a client, there will be a server on the network, that will have some default resources. When you then call findResources() the client discovers the resources it itself exposes.

zolkis commented 7 years ago

This is a bug in the spec. I filed an issue.

zolkis commented 7 years ago

I guess in client mode we'd expect to have an object without the server and platform properties. I propose adding an init(mode) and a stop() function. Why not a parameter to require?

  1. As the spec says, in some implementations the ocf object may be attached to a global object.
  2. Theoretically a script may decide to start in client mode, and later provide a server functionality that depends on the findings in client mode. What do you say?