jimsynz / faye-rails

Simple Rails glue for the Faye messaging protocol.
MIT License
435 stars 79 forks source link

Can I get a response from client side? #50

Open brlo opened 11 years ago

brlo commented 11 years ago

Hello,

I want to take some data on server side (RoR with faye-rails) from client side (Ruby + faye client). The problem is that the client is behind a firewall and because of it, I connecting client to server and wait for any command from it. Client can publish back to channel all requested data but I can't understand how I can take back this message in the server controller after publishing request to client channel.

This is the controller action:

def send_request
    require 'net/http'
    publication = ClientController.publish("/client", params[:query])
    publication.callback do
            @res "[PUBLISH SUCCEEDED]"
    end
    publication.errback do |error|
            @res = "[PUBLISH FAILED] #{error.inspect}"
    end
end

How I can take a response from client in the usual controller?

Thanks a lot.

jimsynz commented 11 years ago

Are you using Rails 4?

brlo commented 11 years ago

Hello. First of all, thanks for your tool. If it's important, I can use Rails 4, but currently I'm using Rails 3.2.14. Thanks for your time.

jimsynz commented 11 years ago

Just checking, because it's break on Rails 4 at the moment :)

I don't really understand the problem, perhaps you can post a gist with the relevant information?

brlo commented 10 years ago

I made it with faye-websocket. Ruby clients (with dynamic IP) connects to my Rails middleware faye-websocket server. When I need information from any client I call the method from middleware and wait N seconds for response from client through websocket.