Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer a direct migration from faye-websockets #87

Open
SamSaffron opened this issue Aug 28, 2012 · 5 comments
Open

Offer a direct migration from faye-websockets #87

SamSaffron opened this issue Aug 28, 2012 · 5 comments

Comments

@SamSaffron
Copy link

This is part feature request, part documentation request.

I am using https://github.com/faye/faye-websocket-ruby in my current project, mainly cause it offers a simple integration point with Rack and Thin.

To get it going it monkey patches Thin so essentially the EM connection is exposed.

I would much prefer to use em-websockets, since

  1. protocol support is way more comprehensive
  2. it is far more active

however

  1. It is unclear if a bind to an existing EM connection semantics is supported, though it seems I could simply initiate a handler. with the connection as an init param
  2. I would have to roll my own monkey patch (I am fine with that) - though I think thin and rainbows should attach the EM connection to env to avoid this nonsense
  3. faye includes native masking https://github.com/faye/faye-websocket-ruby/tree/master/ext/faye_websocket_mask I am unclear about the perf implications

Thoughts?

@igrigorik
Copy link
Owner

Sam, what you've described is pretty much exactly what we did in Goliath to provide websocket support:
https://github.com/postrank-labs/goliath/blob/master/lib/goliath/websocket.rb

As long as you have access to the underlying EM connection object, you should be able to pretty much translate that code to work with thin as well. You just have to map the right Thin callbacks..

@SamSaffron
Copy link
Author

I started writing an adapter, a big issue is that https://github.com/igrigorik/em-websocket/blob/master/lib/em-websocket/connection.rb is not reusable so I need to copy and paste wholesale, perhaps it should be moved to a module?

@SamSaffron
Copy link
Author

Another painful issue seems to be the heavy reliance on httpparser.rb I need to do a bit of magic code converting rack request to httpparser ones

@igrigorik
Copy link
Owner

Not sure how you're structuring your code, but notice that the Goliath code did not have to copy the connection class - we simply implemented the necessary shims and mapped to http_parser.rb.. which is what Goliath uses (no dependencies to em-websocket).

@SamSaffron
Copy link
Author

yeah, I follow, my thin implementation takes a slightly different approach.

I got it going though the secure stuff is not working yet, https://github.com/SamSaffron/thin-em-websocket/blob/master/examples/config.ru

will publish the gem once it is a bit more battle tested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants