Here is the deal. I also wanted to develop a websocket server client with a ruils-based ruby. However, ruby rails are not very friendly with eventmachine. I struggled with having a websocket client, so I was able to copy / cut / paste from an existing library and eventually get the following two additional ones.
Em-Websocket Server
https:
ROR friendly web client client
https:
have the server code in the script directory, the beginning as in ruby code.
pid = Process.spawn("ruby", "web_socket_server.rb",
"--loglevel=debug", "--logfile=#{Rails.root}/log/websocket.log",
:chdir=>"#{Rails.root}/script")
:out => 'dev/null', :err => 'dev/null'
Process.detach pid
Then your client can be used as
ws = WebSocketClient.new("ws://127.0.0.1:8099/import")
Thread.new() do
while data = ws.receive()
if data =~ /cancel/
ws.send("Cancelling..")
exit
end
end
end
ws.close
I want a good friendly em-websocket client compatible with ROR, but not yet able to execute it.
/ , auth. rails. ( auth/db)