Ninja Pirate Marksman

    powersocket

    1.2.0 • Public • Published

    Powersocket

    A tiny library for connecting to Gnip Powertrack streams.

    Usage

    There are two ways to configure PowerSocket:

    Provide three separate User, Password, and Path (just the path section of your PT url) arguments, and a callback for when a tweet arrives:

     
    var powerSocket = require('powersocket');
    new powerSocket.Connection({
      username: process.env.POWERSOCKET_USER,
      password: process.env.POWERSOCKET_PASS,
      path:     process.env.POWERSOCKET_PATH1,
      onTweet:  onTweet
    });
     
    function onTweet(tweet)
      io.sockets.emit('tweet', tweet);
    }

    Or, just provide a full URL that includes your PT username and password, and a callback:

     
    var powerSocket = require('powersocket');
    new powerSocket.Connection({
      url: process.env.POWERSOCKET_URL,
      onTweet:  onTweet
    });
     
    function onTweet(tweet)
      io.sockets.emit('tweet', tweet);
    }

    Your callback will be triggered whenever a new tweet arrives. An error will be raised on any error in the HTTP client.

    Install

    npm i powersocket

    DownloadsWeekly Downloads

    6

    Version

    1.2.0

    License

    ISC

    Last publish

    Collaborators

    • trinary