Real-time chat with push notification
Asked Answered
H

4

6

I am working on a private messasing functionality for my site, is there a way to get push notifications from the server, that the user has received a new message?

the only technique I know is to constantly poll the server via ajax to see if there are new messages, and reload the messenger window if needed.

thanks for any feedback!

UPD: so far the following directions have been identified:

1) Comet
2) BOSH - Bidirectional-streams Over Synchronous HTTP
3) XMPP - this is what google talk is based on

Hampson answered 11/5, 2009 at 8:43 Comment(1)
just a note BOSH and XMPP go hand in hand.Abigail
A
6

You might want to look into XMPP and BOSH. Very comet like and ejabberd combined with nginx can maintain 1000's of connections on a very small box.

Take a look at one of my projects www.vooices.us to see what we have done with XMPP and BOSH.

http://www.ejabberd.im/

http://github.com/ssoper/jquery-bosh/tree/master JQueryBosh - to enable quick and easy access to XMPP over HTTP

It is relativly easy to set up and install.

Paul.

Abigail answered 11/5, 2009 at 9:40 Comment(4)
Yes it works very well. To be fair I have not tried it in IE6, but I have done IE7 and IE8Abigail
The good thing is that it is all javascript from the client perspective.Abigail
If you are checking out Ejabberd it is called http_bind, which maintains connections. You may need a simple reverse proxy in place (so you don't have to have cross domain requests), but nginx can handle all that. There are a couple of other Javascript BOSH libraries, but jquery-bosh is the one I use and it works pretty well for me.Abigail
@Abigail Your website vooices.us seems to be down. Also have you considered using flash sockets at the client end?Follow
G
0

There isn't any way for the server to push information to the client, but you could always use Comet. Yes, you'd be polling the server, but not constantly. You'd keep each connection open for about 30 seconds (that's the interval I've always seen used) and then open a new connection when needed.

EDIT: Adobe Flash allows persistent connections to the server, so you could use that. See this article for details.

Glabrescent answered 11/5, 2009 at 8:47 Comment(4)
I am looking at badoo.com, they are using some flash plugin to get notified, wonder if there is any source code available..Hampson
Ah, yes, I didn't think about that. Flash does allow persistent connections, so that's an option.Glabrescent
Seriously, look into XMPP and BOSH.Abigail
The 30-second interval is also a standard kind of length of time for how long web server processes are allowed to run for before being forced to terminate, especially if your application is going to be run on an arbitary server that you don't have any control over.Ricer
P
0

Sounds like the Comet probably links to some useful stuff (Look into Google's GTalk):

http://alex.dojotoolkit.org/2006/02/what-else-is-burried-down-in-the-depths-of-googles-amazing-javascript/

Perrotta answered 11/5, 2009 at 9:28 Comment(0)
S
0

There are a lot of good libraries that help you to do this

XMPP - BOSH is a good combination which I use on my websites

XMPP servers

Ejabberd, Openfire I use ejabberd

You can use Strophe along with Ejabberd to capture notifications in javascript. If you want to send notifications from code

There are libraries like JAXL and XMPPHP that let you do this, but this is in PHP.

Sultan answered 4/6, 2011 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.