|Piper Push Cache||Documentation||Download||Samples||Contact|
Piper Push Cache has built in JSON records that report on the number of connections. One is all the connections since Piper was started and the other is all the currently open connections. This sample displays those values along with the websocket connection status. It is a quick way to see how cached values are pushed to web pages using websockets.
The second part of this sample creates a new set of records and displays the raw JSON on the page. The cache modification port is used to modify the cache which is immediately reflected on the web page.
To try the sample a web browser is needed and of course the piper app. Starting from the downloaded piper folder use the following line to start piper.
$> bin/piper -c samples/connect_counter/piper_cfg.json
This will start piper listening on port 7660 for HTTP GET requests and on port 7661 for PUT and DELETE request that modify the cache.
To verify that piper is working open up a new window in the browser and type in the URL for the view port of localhost:7660/hello.html. A page should be displayed with the connection status, connections made, and the open connections.
A refresh should show the total connections doubling but the open connections remaining at one. The open connection is the websocket connection.
Now open a second windown in the browser and go to the same URL. The open connection count should show 2 in both windows and the total connections should increase.
The next step is to try out creating a new record. To do this any tool that can send a PUT request can be used. A Ruby script has been provided to simplify the process though. In the bin directory is a script that will send a PUT request to piper. Use this script to add a Pipe record that is the contents of the copper.json file.
$> bin/piper_put.rb localhost:7661 pipe-copper samples/connect_counter/copper.json
Now click on the link at the bottom of the page in the browser to go to localhost:7660/pipe.html. The copper pipe JSON should be displayed. Add another Pipe record and note that it replaces the copper record. Curl is used this time to update the record.
$> curl --upload-file samples/connect_counter/pvc.json http://localhost:7661/pipe-PVC