If I wanted to translate my node application that uses socket.io into a Ruby on Rails application what are the options for replacing socket.io? (Essentially looking for a socket server for Ruby)
http://socket.io/
Plan to translate the application below: http://www.tokbox.com/blog/creating-chat-roulette-with-node-js-socket-io-and-opentok/
I'd recommend the Faye Ruby implementation as a solid server-side realtime component. It's not a direct port of socket.io but provides you with the realtime infrastructure and some well define messaging concepts that will help you port most realtime applications.
You can find more options via the realtime web tech guide.
Did you look at the Plezi framework?
You can use it either as a separate framework or to augment Rails/Sinatra by adding websocket functionality.
It runs using the Iodine server and supports native websockets, RESTful routes and HTTP streaming, so it's easy to have a fallback position such as long-pulling, much like socket.io does when web sockets don't work.
It's interesting and easy to develop with and has native support for Redis, so it allows websocket broadcasts between processes and machines... although it's still under development, it's full of potential.
A broadcast/echo WebSocket app can look like this:
require 'plezi'
class Echo
def index
"this is an echo server - use websockets to connect. test with: https://www.websocket.org/echo.html"
end
def on_message data
_echo data
broadcast :_echo, data
end
def _echo data
response << data
end
end
Plezi.route '/', Echo
You can actually put the code in the irb console and the server will start the moment you exit irb using the exit
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With