Hexagon / node-telldus

Node bindings for telldus-core
Other
34 stars 10 forks source link

tdInit only available through getDevices() #19

Closed Hexagon closed 10 years ago

Hexagon commented 10 years ago

This should be a separate function

kmpm commented 10 years ago

And tdClose as well then I guess or how is that solved today?

Hexagon commented 10 years ago

Correct! That's not handled at all today

nilzen commented 10 years ago

I've read somewhere, can't find where now, that tdInit() only should be called once. So I guess that there should be an function that checks a boolean that is indicating if the Tellstick is initialized or not, and that function should be called in each of the "command functions".

Not sure when/where we should call tdClose(), I guess you normally never "shut down" node app.

nilzen commented 10 years ago

http://www.telldus.com/forum/viewtopic.php?f=7&t=2188#p14262

Hexagon commented 10 years ago

Yeah that's a problem, we need to decide if we wan't to leave the tdInit call to the user, via telldus.tdInit(callback) or if we want to make logic in the js-wrapper that run tdInit on the first call and never again. The latter version is imho the cleanest option, and the first option is the most "library-agnostic".

kmpm commented 10 years ago

I'm all for running it automatically in the wrapper.

nilzen commented 10 years ago

I agree.

Hexagon commented 10 years ago

Agreed :) I'll add the core c++ stuff later, after that you'll be able to call telldus.tdInit(callback); (and close, if needed)

Hexagon commented 10 years ago

Untested as i dont have access to my tellstick right now. Short documentation in commit description, did not change telldus.js to avoid merge conflicts.

kmpm commented 10 years ago

I have now tested, using my own changes to telldus.cc and .js, with and without tdInit/tdClose and I really can't make out any difference... Anyone got anything.

Hexagon commented 10 years ago

I know nothing, seems like some people use init and close to successfully restart the library on failures. Telldus documentation says that tdInit "initializes the library", so i guess the best bet is to run it for compability with future versions.

kmpm commented 10 years ago

tdInit is now called on module load. tdClose on process exit. Don't know if it's the best way of doing it but it seems to work.

Hexagon commented 10 years ago

That should be entirely fine, great :+1: