thibauts/node-castv2 — pull request #8 by richardkazuomiller (2014-11-16 17:41:41+00:00)
Title: Fix socket error

First of all thanks for making this! (^_^)

This checks if `ps` is defined before trying to send a message. It's hard to reproduce but using `chromecast-player` I've gotten an error caused by trying to refer to a `null` or `undefined` `ps`, most likely due to network issues but I'm not entirely sure. I tested it playing a few hours of video and got the `Attempted to send message after connection was closed` message a few times so this definitely fixes it, although I think some work still needs to be done on a higher level (i.e in `castv2-client`) to make sure the connection is open before trying to send messages.