koush/android-websockets — pull request #19 by cpeterso (2013-05-23 20:00:45+00:00)
Title: Avoid mSocket NPE if WebSocketClient.disconnect() is called twice

If WebSocketClient.disconnect() is called twice quickly, two runnables might be posted to because mSocket might not be null yet if the first runnable has not be run yet.

This change double-checks whether mSocket still needs to be closed when the runnable eventually runs. It also ensures mSocket = null and mConnected = false if mSocket.close() throws an IOException.