Giter Club home page Giter Club logo

node-sentiance-firehose's Introduction

Sentiance Firehose

Node.js module for connecting to the Sentiance Firehose.

Adding to project

npm install https://github.com/sentiance/node-sentiance-firehose --save

Subscribing for messages

Connection requires a valid application ID, stream definition ID and a bearer token that has access to the data the stream is providing.

The application ID is the ID you are using in your mobile app configuration.
The bearer token is either the SDK user/device token or an application backend token that can be obtained using the app manager.

var Firehose = require('sentiance-firehose');
// Firehose.enableDebug(); // Show log messages

var client = new Firehose.FirehoseClient(applicationId, streamDefinitionId, bearerToken); 

/**
 * Called on every data update the stream emits
 * @param data      data projection
 * @param errors    list of errors that have happened when creating the projection
 * @param metadata  will hold additional information regarding the processing time, source of trigger, ...
 */
client.on('data', (data, errors, metadata) => {
    // Implement custom data handling here.
    // Push the data to an internal queue, filter & process it in realtime, ...
    console.log(JSON.stringify(data, null, 2));
    if(errors) {
        console.error(errors);
    }
});

client.connect();

Testing

Tested with node 4.6.1

Install:

npm install

Testing:

node tests/single-instance.js APP_ID STREAM_DEFINITION_ID BEARER_TOKEN
node tests/multi-instance.js APP_ID STREAM_DEFINITION_ID BEARER_TOKEN

node-sentiance-firehose's People

Contributors

roelentless avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.