christopher-dG / go-obs-websocket

Go client for obs-websocket
MIT License
85 stars 26 forks source link

panics if OBS is killed.. #4

Closed afriza closed 4 years ago

afriza commented 4 years ago

I handled OBS event Exiting and then disconnects properly.

But if OBS is killed, after 1000 iteration, the Client.poll() panics.

Furthermore, according to Gorilla websocket overview and Conn.NextReader() documentation:

Applications must break out of the application's read loop when this method returns a non-nil error value. Errors returned from this method are permanent. Once this method returns a non-nil error, all subsequent calls to this method return the same error.

I propose to fix this by checking if the returned error is *CloseError then we Disconnect the client.. If you are okay with the fix, I will send a pull request..