English 中文(简体)
铁路实时通知系统
原标题:Rails faye realtime notification system

试图建立简单的法耶实时通知制度,以便我能够对某些行动实施某种分类。 这一概念相对简单,尽管在阅读传闻文件后,并没有确定在座右边的道路。

现思

  • One unique faye channel per logged-in user, so you can push a action (popup, set text) to a certain user only
  • One div in my app layout that I can write text to
  • One div in my app that holds layout for a popup

现在,我看到了从控制者/行动方法中产生的法耶但干.的铁路线。 我不想在 d中插入一 st,只是从任何地方称为“联合文件”功能(建立申请助手是我所认为的好想法),我只想做像“精彩的javascript set_text”和执行javascript show_popup。

用法耶建设这种功能的最佳方式是什么,基本上我只得去做。

  • Execute a javascript function on a certain Faye channel

To accomplish the popup and text message. A bit lost on this anyone can point me in the right direction or maybe have build such functionality already? thx in advanche!

最佳回答

在服务器方面,你可以做些什么(这种需要活动):

client = Faye::Client.new( http://localhost:9292/faye )
client.publish( /notifications/1 ,  alert(1); )

Or via HTTP:

message = {:channel =>  /notifications/1 , :data =>  alert(1); }
uri = URI.parse("http://localhost:9292/faye")
Net::HTTP.post_form(uri, :message => message.to_json)

然后,在客户方面,你可以做任何数据。

var client = new Faye.Client( http://localhost:9292/faye );
client.subscribe( /notifications/1 , function(data) {
  eval(data);
});

仅以你想要执行的任何联合材料取代<代码>alert(1);。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签