]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/daemons/twitterdaemon.php
Merge branch 'nightly' of gitorious.org:social/mainline into nightly
[quix0rs-gnu-social.git] / plugins / TwitterBridge / daemons / twitterdaemon.php
index 851d191dd2296fe5a02f2ae3e84f77288975fd80..e563f534934ce2a4ce09c8eeaa99079a95b53e51 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
 
 $shortoptions = 'fi::a';
 $longoptions = array('id::', 'foreground', 'all');
 
-$helptext = <<<END_OF_XMPP_HELP
+$helptext = <<<END_OF_TWITTERDAEMON_HELP
 Daemon script for receiving new notices from Twitter users.
 
     -i --id           Identity (default none)
@@ -31,11 +31,9 @@ Daemon script for receiving new notices from Twitter users.
                       (requires Stomp queue handler, status_network setup)
     -f --foreground   Stay in the foreground (default background)
 
-END_OF_XMPP_HELP;
+END_OF_TWITTERDAEMON_HELP;
 
-require_once INSTALLDIR.'/scripts/commandline.inc';
-
-require_once INSTALLDIR . '/lib/jabber.php';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
 
 class TwitterDaemon extends SpawningDaemon
 {
@@ -82,13 +80,11 @@ class TwitterMaster extends IoMaster
      */
     function initManagers()
     {
-        if (common_config('twitter', 'enabled')) {
-            $qm = QueueManager::get();
-            $qm->setActiveGroup('twitter');
-            $this->instantiate($qm);
-            $this->instantiate(TwitterManager::get());
-            $this->instantiate($this->processManager);
-        }
+        $qm = QueueManager::get();
+        $qm->setActiveGroup('twitter');
+        $this->instantiate($qm);
+        $this->instantiate(new TwitterManager());
+        $this->instantiate($this->processManager);
     }
 }
 
@@ -100,12 +96,8 @@ class TwitterManager extends IoManager
     const USERS_PER_STREAM = 100;
     const STREAMS_PER_SECOND = 20;
 
-    protected $twitterStreams;
-    protected $twitterUsers;
-
-    function __construct()
-    {
-    }
+    protected $streams;
+    protected $users;
 
     /**
      * Pull the site's active Twitter-importing users and start spawning
@@ -116,6 +108,7 @@ class TwitterManager extends IoManager
      */
     protected function initStreams()
     {
+        common_log(LOG_INFO, 'init...');
         // Pull Twitter user IDs for all users we want to pull data for
         $flink = new Foreign_link();
         $flink->service = TWITTER_SERVICE;
@@ -144,9 +137,9 @@ class TwitterManager extends IoManager
      * Prepare a Site Stream connection for the given chunk of users.
      * The actual connection will be opened later.
      *
-     * @param $users array of Twitter-side user IDs
+     * @param $userIds array of Twitter-side user IDs
      */
-    protected function spawnStream($users)
+    protected function spawnStream($userIds)
     {
         $stream = $this->initSiteStream();
         $stream->followUsers($userIds);
@@ -213,7 +206,7 @@ class TwitterManager extends IoManager
                 $sockets[] = $socket;
             }
         }
-        return $streams;
+        return $sockets;
     }
 
     /**
@@ -272,7 +265,7 @@ class TwitterManager extends IoManager
      *
      * @fixme add more event types as we add handling for them
      */
-    protected function setupEvents(TwitterStream $stream)
+    protected function setupEvents(TwitterStreamReader $stream)
     {
         $handlers = array(
             'status',