I have a question. I used faye to update part of the page for all clients on this page. But I am embarrassed. How to update part of the page only for certain users. In my case, I want to notify the user of a new message. But I do not know how to do this. I know how to notify all people on a particular page. For example, in my message model, I created js
<% broadcast "/posts/new" do %> $('#posts_list').prepend('<%= escape_javascript(render(@post)) %>'); $("#posts_list li:first").hide().fadeIn("slow"); <% end %>
and broadcast function
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
I also 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 railscast.)
How do I need to think? Thanks in advance!
Pavel source share