thibauts / node-castv2-client

A Chromecast client based on the new (CASTV2) protocol
MIT License
648 stars 95 forks source link

Platform should emit a close on socket close? #95

Open i8beef opened 4 years ago

i8beef commented 4 years ago

I'm trying to implement something a bit more long lived than the examples, and I think I hit a snag. The heartbeat maintains an active connection, and on a timeout looks like it would emit an error event from the Platform to indicate said timeout.

However on a forceful close of the socket, say me walking over an unplugging the Google Home to simulate, the socket close looks like it is wrapped ok by castv2's client and emitted as a "close" event that the Platform grabs and does some internal cleanup... but then it fails to emit a "close" event from the Platform, meaning as a caller, I don't seem to have a way to be notified of this event?

Let me know if I'm missing something here for why that doesn't emit, and if there's a different way to identify this state.

i8beef commented 4 years ago

Played around a bit and realized I could register my own handlers to Platform.client instead... is that the expected path here, or does my assertion that an explicit close from Platform stand?