Skip to content

Loading…

Support for on_error callback #17

Open
thilko opened this Issue · 3 comments

3 participants

@thilko

Hello,

since I would like to track TCP errors I would appreciate the support of on_errorcallback on WebSocketConnection.

Thx,

Thilko

@DanKnox
websocket-rails member

Hey, sorry for the delayed response. We are almost done with a final push on a large project for a client.

I just added very rough support for handling the on_error case. You can see the addition in commit 3d13a7d. With this commit, the WebSocketRails javascript client dispatcher will fire a connection_error event when the WebSocket.onerror function is called. You can use it just like you would bind to any other event.

dispatcher.bind('connection_error', function(data) { console.log("connection error!") });

If you want to use this, be sure to clone the master branch of the repository. I haven't released this on rubygems yet. Also, this I only added the error event for WebSocket connections. If you are using the HTTP streaming the error event will not fire.

I am going to implement the suggestion by @mszoernyi in issue #15 very soon to make handling the connection closed and connection error events easier. It will be similar to the actual WebSocket interface.

Instead of triggering dispatcher events, you will be able to do the following:

dispatcher.on_close = function() { console.log('closed') }
dispatcher.on_error = function() { console.log('error') }

I will have a lot more time next week and will hopefully be pushing out a big new release soon. There are a lot of new features that I am excited about.

Let me know if there is anything else you would like to see.

@thilko
@brumm

Instead of triggering dispatcher events, you will be able to do the following:

dispatcher.on_close = function() { console.log('closed') }
dispatcher.on_error = function() { console.log('error') }

What happened to this? I'd love to be able to handle errors and disconnects on the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.