Adding heartbeat, on socket close code and close reason, and refactoring code to use WebSocket enums rather