Overview
Heimdallr is a system built on top of socket.io for transferring and storing data in real-time. It connects a network of providers to a network of consumers. A provider is a source of data. The provider sends that data to the Heimdallr server, which then stores it and relays it to any consumers that are currently subscribed to that particular provider. If you would like to get started, request an authentication token by emailing us.
Usage
In the browser
First install bower if you don't already have it. Then grab the package using bower:
bower install heimdallr-client --save
Then include a script tag with your HTML:
In node
Install node if you don't have it. Then grab the package using npm:
npm install heimdallr-client -g
The -g
flag is optional but it gives you easy access to the post-schemas utility (see Set Subtype Schemas). Then you just need to use require to include the module in your script:
var heimdallrClient = ;
Examples
Set Subtype Schemas
For the examples below we would need to define the different event, sensor, and control packet subtypes that we want to use with JSON schemas. The Heimdallr server uses these schemas to validate the packets that it receives as well as make intelligent visualizations of your data. So we might have a file called packet-schemas.json
that contains:
If you installed heimdallr-client with npm using the -g option then from the command line you can do:
post-schemas <consumerAuthToken> -u <uuidOfProvider> -f packet-schemas.json
Otherwise you'll need to do:
node /path/to/heimdallr-client/bin/post-schemas <consumerAuthToken> -u <uuidOfProvider> -f packet-schemas.json
If you installed with npm then /path/to/heimdallr-client
should probably be something like ./node_modules/heimdallr-client
or if you installed with bower ./bower_components/heimdallr-client
. Multiple provider UUIDs or .json files can be specified by using the -u or -f flags multiple times. Again this assumes you have node installed. If you don't have node installed you will need to make the HTTP POSTs on your own. The curl alternative might look something like:
curl -H "Content-Type: application/json" -H "Authorization: Token <consumerAuthToken>" -X POST -d '{"packetType": "event", "subtypeSchemas": {"youSensorSubtype": {}, ...' https://heimdallr.co/api/v1/provider/<uuidOfProvider>/subtype-schemas
Provider
var provider = providerAuthToken; // Respond to controls from consumersprovider; // Broadcast event data provider; // Broadcast sensor dataprovider;provider; // Broadcast binary dataprovider; // Signal server that a persistent control has been finishedprovider;
Consumer
var consumer = consumerAuthToken; consumer; // Start listening to a particular providerconsumer; // Stop listening to a particular annoying providerconsumer; // Specify what you actually want to hearconsumer; // Get the latest events emitted by a providerconsumer; // Boss a provider aroundconsumer; // Tell a provider to start streaming and start listeningconsumer; // Tell a provider to stop streaming and stop listeningconsumer;