Support for error codes in case of a connection being closed

At the moment, error codes on connection close are not checked to conform to the Pusher protocol (http://pusher.com/docs/pusher_protocol).
This also fixes an issue where clients would try to connect again and again if ```connectAutomatically``` is enabled, but e.g. a wrong application key was supplied.