Question

I have a question. I was using faye, for updating part of page for all clients at this page. But I am woundering. How can I make updating part of the page only for specific users. In my case, I want to notify user about new message. But I dont know how to do this. I only know how to notify all people on certain page. For example , in my post model I have create js

<% broadcast "/posts/new" do %>
$('#posts_list').prepend('<%= escape_javascript(render(@post)) %>');
$("#posts_list  li:first").hide().fadeIn("slow");
<% end %> 

and broadcast function is

def broadcast(channel, &block)
        message = {:channel => channel, :data => capture(&block)}
        uri = URI.parse("http://localhost:9292/faye")
        Net::HTTP.post_form(uri, :message => message.to_json)
end

also i had a faye client and code

$(function() {
  var faye = new Faye.Client('http://localhost:9292/faye');
  faye.subscribe("/posts/new", function(data){
    eval(data);
  });
});

(all this was done according to the railscast.)

In what way I need to think? Thanks in advance!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top