推式通知类似于使用Rails和jQuery的Facebook [英] push-style notifications similar to Facebook with Rails and jQuery

查看:83
本文介绍了推式通知类似于使用Rails和jQuery的Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个类似Facebook的推送通知系统.每当Facebook想告诉您一些信息(例如某人对某条信息发表评论,为您添加标签等)时,您都会在屏幕的左下角看到一条小通知.它淡入淡出.

I want to create a push notification system like Facebook. Whenever Facebook wants to tell you something (like that someone commented on a post, tagged you, etc), you'll see a small notification show up in the bottom left corner of the screen. It fades in and fades out.

如何使用jQuery和Rails构建这样的系统?它甚至如何工作? JS是否不断询问服务器是否有新通知?"还是服务器以某种方式 push 将此服务推入.

How do I build a system like this with jQuery and Rails? How does it even work? Does JS constantly ask the server, "is there a new notification?" or does the server somehow push to this service.

现在,如果某个用户向其他用户发送了一条消息(例如),我可以向该用户的队列添加一条通知,说您有一条新消息",但是直到重新加载页面后该消息才会出现...

Right now, if a user sends another user a message (for example), I can add a notification to the user's queue saying "you have a new message", but it won't appear until a page reload...

推荐答案

剑圣看起来真的很酷,我看到它很久以前就已降级,现在它已在node.js之上重写.好的.您必须安装redis和node.js并运行一个node.js服务器,其余的工作很简单.

Juggernaut looks really cool, i saw it demoed a long time ago, now it is rewritten on top of node.js. Nice. You have to install redis and node.js and run a node.js server and the rest is dead-easy.

Pusherapp.com看起来也很酷,确实值得,但是至少您不必安装和运行额外的服务(守护进程,扩展它们……).

Pusherapp.com also looks cool, it is paying, but at least you don't have to install and run extra services (and daemonise, scale them, ...).

但是,如果负载不是太大,我希望保持简单,只需使用javascript进行轮询即可.您可以轻松地编写自己的代码(这不太难),但是jquery已经存在一些非常好的插件.例如 PeriodicalUpdater .

But, if the load is not too big, i would prefer to keep things simple, and just poll using javascript. You could easily write your own (it is not too hard), but some very good plugins already exist for jquery. For instance PeriodicalUpdater.

这篇关于推式通知类似于使用Rails和jQuery的Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆