msloth / lgtv.js

Control LG WebOS TV using node.js
MIT License
249 stars 119 forks source link

Error on start app #11

Closed berkaytheunicorn closed 2 years ago

berkaytheunicorn commented 8 years ago

Hey me again :)

I found three issue on this.

first, app names returns with "_default" at the end so before open one we need to remove "_default" from name.

second, some inputs could be listed as apps like "HDMI 1" but their ids is integer like "81273" and these won't open.

and last I got this but events works like I can open live tv or spotify but still get this.

Uncaught Exception:
TypeError: fn is not a function
  at /Users/berkaey/Desktop/remote-app/node_modules/lgtv/index.js:698:9
  at EventEmitter.<anonymous> (/Users/berkaey/Desktop/remote-app/node_modules/lgtv/index.js:269:9)
  at EventEmitter.g (events.js:260:16)
  at emitOne (events.js:77:13)
  at EventEmitter.emit (events.js:169:7)
  at WebSocketConnection.<anonymous> (/Users/berkaey/Desktop/remote-app/node_modules/lgtv/index.js:106:26)
  at emitOne (events.js:77:13)
  at WebSocketConnection.emit (events.js:169:7)
  at WebSocketConnection.processFrame (/Users/berkaey/Desktop/remote-app/node_modules/lgtv/node_modules/websocket/lib/WebSocketConnection.js:547:26)
  at /Users/berkaey/Desktop/remote-app/node_modules/lgtv/node_modules/websocket/lib/WebSocketConnection.js:321:40
  at doNTCallback0 (node.js:419:9)
  at process._tickCallback (node.js:348:13)
berkaytheunicorn commented 8 years ago

ok I can just fix the last one with adding and empty function.

msloth commented 8 years ago

I'll have a look at the first two, although some example output from the TV would be great (including what command you ran).

As for the third one it seems I've forgotten a check like if(fn && typeof(fn) === 'function') {fn();}, I'll have a look.

msloth commented 8 years ago

Ah, yeah, there are a bunch of if (typeof fn === 'function') { in the code, I'll replace them with the above mentioned so that one can invoke them without defining a callback. I'll open a separate issue for this.