views:

183

answers:

2

i am a newbie of nginx , and i am using nginx as a comet server by nginx_http_push_module

i have two question:

1,how can i save the messages which recieved by nginx_http_push_module into databases ?

2,how can i get listeners list of a channel ?

thanks~

A: 

1,how can i save the messages which recieved by nginx_http_push_module into databases ?

You have to subcribe to the channel you're interested in on the server side, and store each message in the database as they arrive.

You could use cURL in PHP, for example, to repeatedly long-poll the channel (you will have to set an appropriate timeout and the right caching headers: If-None-Match and If-Modified-Since).

2,how can i get listeners list of a channel ?

Side note: nginx http push module protocol is dead simple, this is not bayeux. A subscriber/listener in this module is simply an active HTTP connection on a subscriber URL. For example, if you use interval-polling instead of long polling, you will be counted as a subscriber only for the (very) short time during when the connection is established.

This is why a list of listeners of a channel doesn't make a lot of sense with this module.

You can however get the number of active subscribers of a channel by issuing a GET request to the publishing URL, but I seriously doubt you could do anything with this.

Clément
A: 

1 - nginx does not receive any message from clients, only from your application at publish url which should be protected.

2 - you can implement some javascript tricks with body.onload and unload to create a chat user list for example.

VitalieL