views:

145

answers:

1

The Nginx approach to HTTP PUSH is relatively simple. There are 3 party involve: Subcriber (receiver), Publisher (sender), and the server itself act as multicast server.

Nginx can also separate into different channel with different channel ID that user can access.

But I still don't know how to authorize/limit content only for logged in user, or send only the data needed to that user, instead of multicast it to anyone know about the channel ID.

If possible, are there anyway to use only a channel and send data to user selectively?

Currently i am running on the same database, but the Sender is writen in ruby, using nginx, and the front end is writen using PHP/GWT.

Thank you very much

+1  A: 

This is my setup: >

              location = /broadcast/sub {
                   default_type  text/json;
                  set $push_channel_id $arg_channel;
                  push_subscriber;
                  push_subscriber_concurrency broadcast;
                  push_channel_group broadcast;
              }

              location = /broadcast/pub {
                  set $push_channel_id $arg_channel;
                  push_publisher;
                  push_min_message_buffer_length 5;
                  push_max_message_buffer_length 20;
                  push_message_timeout 10s;
                  push_channel_group broadcast;
              }

I send new messages with curl

    $ch = curl_init($pub_url);
    $data = array('status' => $message);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:
text/json"));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $return = curl_exec($ch);
    curl_close($ch);

Thanks for any hints...