How to use the pubnub.subscribe 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
type: sequelize.DOUBLE,
        allowNull: false
    }
}, {
    timestamps: false,
    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,
github walmartlabs / mock-server / lib / watcher.js View on Github external
init: function(repo) {
      if (!config.isStandalone) {
        return;
      }

      pubnub.subscribe({
          channel: process.env.PUBNUB_CHANNEL || 'demo'
        },
        function(msg) {
          repo.currentBranch(function(err, branch) {
            if (err) {
              console.error('Watch failed:', err);
              return;
            }

            console.error('watch branch', branch, msg.ref, 'refs/heads/' + branch, msg.ref === 'refs/heads/' + branch);
            if (msg.ref === 'refs/heads/' + branch) {
              console.log('Updating branch', branch, 'updated to', msg.after);
              admin.pull(repo, branch, function(err) {
                if (err && !err.upToDate) {
                  return console.error(err);
                }

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