rikulo/stomp — pull request #8 by revelfire (2014-01-22 14:35:42+00:00)
Title: 2 sets of fixes. Connection error handling and first frame accessibility

Hi Tom. Some important details on this request:

* Fixes issue where connection failures due to 302 and other http (upgrade request) failures cause the client to NPE by allowing to define a connectionError function to pass in and handle. Bug was system was trying to invoke a null onClose handler because websocket was not yet established. This was uncovered in working with Spring4 websocket support with security in place.

* Fixes the need (and lack of ability) to get information about the connection frames. Use case here was Spring STOMP/Websocket implementation passes custom header user-name on CONNECT and there was no way to get ahold of it.

Probably you won't want to adopt this pull request in whole. Unfortunately I ended up changing the basic interface - the Future from connect() now returns a Map instead of a StompClient.

connecting.complete({ "stompClient": this, "frame": frame });

There may be a better way to do this like "'stompClient.getFirstFrame()" or something. I can make appropriate changes if you want to make a suggestion, and offer another pull request. Or if you make the changes please let me know.

Another thing that might be nice is to be able to get knowledge of the status code from the connection attempt. Right now I just have to guess that if it didn't work, it was due to 302. It wasn't immediately obvious how to fix that in the websocket stuff.