Pervasive is a simple prototype of a distributed and asynchronous resource dispatcher. The typical scenario is as follows. A user submits a
resource to Pervasive indicating the topics that resource is related to as well as the name of the file, where the content of the resource is
stored. Pervasive then identifies the devices, which might be interested in displaying the resource.
Pervasive is implemented in Node.js (using both javascript and coffeescript)
Go to http://nodejs.org/ for more information about Node.js and its installation.
If you are on Mac OS X and using homebrew as your package manager, the following command should do.
When cloning the repository, make sure to include the submodules (with the right versions).
brew install --force -v node
If you do not own /usr/local, you should use sudo. You can own /usr/local using the chown command You should also install npm, the node.js package manager.
To use our small app, first start the web server
node pervasive_server_ws
or
node pervasive_server_tcp
At this point, you have two choices:
- Either use a TCP connection between the devices and Pervasive
- Or use WebSockets
The TCP version of Pervasive requires to use the file local_manager_tcp instead of local_manager. In that case you need to start the devices as TCP connections. You could use Telnet or netcat. Below, is an example with netcat.
nc localhost prt_number
Here, you don't have to do anything. The devices will be created for you automatically and the connections established as well.
Finally, open a Web connection as follows. Here again you can just do if from the terminal with curl.
curl -d "topic=val&topic=energy&file_name=ad1.txt" localhost:8080 (the web server is running on port 8080)
The resource will be assigned depending on the topics and the content of the file ads/myres will be sent to the devices too.
Who can really resist coffeescript these days? There is a coffee-script port of Pervasive coming out soon. The new coffeescript port is available in pervasive_coffee
José G. Quenum