Adjusted the code style, added documentation and fixed WebSocket.connected. Fixes issue #169.

WebSocket.close was using dataAvailableForRead instead of !empty to check if there is any more data to read.