To get old messages you can use a backtrack, an event id or a time in the past to specify a start point.
All control methods use some HTTP headers by default, except for backtrack.
But they can use other methods also, like URL parameters.
To deliver old messages it's necessary to properly configure the directives "push_stream_store_messages", "push_stream_max_messages_stored_per_channel" and "push_stream_message_ttl".
*Using backtrack:*
<pre>
# To get the last 4 messages from channelA, the last 2 messages from channelC and no old messages from channelB
When a message is published it receives a time and a tag value.
The tag is used to untie messages published on the same second.
These values are available to the message template using the ==~time~== and ==~tag~== patterns, and also on headers "Last-Modified" and "Etag" when on long-polling mode.
<pre>
# publish a message on t1
curl -s -v -X POST 'http://localhost/pub?id=channelA' -d '1'
# publish another message on t2
curl -s -v -X POST 'http://localhost/pub?id=channelA' -d '2'
# publish another message on t2
curl -s -v -X POST 'http://localhost/pub?id=channelA' -d '3'
# publish another message on t3
curl -s -v -X POST 'http://localhost/pub?id=channelA' -d '4'
# Get the messages published after the t2 time, tag 1
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
Configure your server like suggested bellow. You should complete this configuration with other directives according with target application.
Configure your server like suggested bellow. You should complete this configuration with other directives according to the target application.
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .
Using an invisible iFrame on the page to receive the messages and pass them to main page.
Using an invisible iFrame on the page to receive the messages and pass them to main page.
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
Configure your server like suggested bellow. You should complete this configuration with other directives according with target application.
Configure your server like suggested bellow. You should complete this configuration with other directives according to the target application.
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .
@@ -3,7 +3,7 @@ h1(#long_polling). Long Polling <a name="long_polling" href="#"> </a>
...
@@ -3,7 +3,7 @@ h1(#long_polling). Long Polling <a name="long_polling" href="#"> </a>
Using PushStream to receive the messages through long polling technique.
Using PushStream to receive the messages through long polling technique.
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
Configure your server like suggested bellow. You should complete this configuration with other directives according with target application.
Configure your server like suggested bellow. You should complete this configuration with other directives according to the target application.
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .
Using PushStream to receive the messages through JSONP technique.
Using PushStream to receive the messages through JSONP technique.
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
Configure your server like suggested bellow. You should complete this configuration with other directives according with target application.
Configure your server like suggested bellow. You should complete this configuration with other directives according to the target application.
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d "Some Text"*.
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d "Some Text"*.
_The configuration in the example is the same used on long polling, just forcing the use of JSONP, this is automatic when the domains are different_
_The configuration in the example is the same used on long polling, just forcing the use of JSONP, this is automatic when the domains are different_
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
Configure your server like suggested bellow. You should complete this configuration with other directives according with target application.
Configure your server like suggested bellow. You should complete this configuration with other directives according to the target application.
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d =="Some Text"==* .