How to use the pubnub.addListener function in pubnub

To help you get started, we’ve selected a few pubnub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sfrechette / stream-sequelize-node / ingest.js View on Github external
freezeTableName: true
});

// Initialize PubNub client
var pubnub = new pubnub({
    ssl: true,
    subscribe_key: 'sub-c-4377ab04-f100-11e3-bffd-02ee2ddab7fe'
});

// Subscribe (listen on) to channel 
pubnub.subscribe({
    channels: ['pubnub-market-orders']
});

// Handle message payload
pubnub.addListener({
    message: function (message) {
        console.log(message.message);
        connection.sync({
            //logging: ()=>{} 
        })
        .then(function () {
            // Build and Save message stream to database 
            var orderInstance = order.build({
                order_time: message.message.timestamp,
                trade_type: message.message.trade_type,
                symbol: message.message.symbol,
                order_quantity: message.message.order_quantity,
                bid_price: message.message.bid_price
            })
            //orderInstance.save()
                //if (Math.random() > .9) {

pubnub

Publish & Subscribe Real-time Messaging with PubNub

SEE LICENSE IN LICENSE
Latest version published 5 days ago

Package Health Score

86 / 100
Full package analysis