alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
317 stars 97 forks source link

Improved handling of unexpected disconnects #228

Closed gizmotronic closed 11 years ago

gizmotronic commented 11 years ago

This change builds on @DubbyTT's previous work, adding an event trigger for the case where Turntable is down (responding with an 302 error instead of JSON), for a name lookup or other connection issue in whichServer, and for the case where a firewall/proxy issue causes the WebSocket to remain up, but we are nevertheless not seeing valid server responses.

This change also renames the "wserror" event to "error" for two reasons:

  1. Is it a WebSocket error, or a whichServer error?
  2. It's consistent with the Events class documentation.

(I'm deliberately not including a compiled version in this request. Please either use a CoffeeScript test harness or compile the source using the project Makefile.)

technobly commented 11 years ago

@alaingilbert Actually, @Izzmo probably does know when his bots are offline since he's written a master bot monitoring process and modified the TTAPI just like I did and @yayramen did.

I still don't want my monitor process to constantly be restarting the bot when there is a way to handle it properly and gracefully.

@alaingilbert you just emit 'disconnected' when you know you've done something to disconnect the bot... websocket error, whichServer and transparent proxy issue. Other than that, there's really no other errors that the TTAPI has right now.. besides maybe that bad roomid error, which is already handled in place.

alaingilbert commented 11 years ago

@DubbyTT Please stop complaining about the problems you can have with other members of the community. And keep your comments constructifs. (It's good for everyone else too)

That being said, the way we throw an error when the roomid is invalid is not good either. I believe we should emit an error because this is what it is, and it would be easier to catch if we ever want to add some logic when a wrong roomid is used.

oldramen commented 11 years ago

I should pay more attention to github. I'm not handling errors at all, really. Woo! And my wrapper reboots my bot if they're disconnected from TT...but disconnected seems like it could come in handy. To the code!