From ccf45d454c68f7f667d07e0db608569e049ec285 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 26 Apr 2009 15:08:49 -0400 Subject: Lots of tweaking to make things work Did some tweaking and maneuvering to make things work. This version will now show a "notice received" alert box -- lots of progress! Had to test with Java server, not Python server. --- plugins/Comet/CometPlugin.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'plugins/Comet/CometPlugin.php') diff --git a/plugins/Comet/CometPlugin.php b/plugins/Comet/CometPlugin.php index 10f8c198c..f60d40075 100644 --- a/plugins/Comet/CometPlugin.php +++ b/plugins/Comet/CometPlugin.php @@ -56,6 +56,8 @@ class CometPlugin extends Plugin { $timeline = null; + $this->log(LOG_DEBUG, 'got action ' . $action->trimmed('action')); + switch ($action->trimmed('action')) { case 'public': $timeline = '/timelines/public'; @@ -64,16 +66,18 @@ class CometPlugin extends Plugin return true; } - $action->element('script', array('type' => 'text/javascript', - 'src' => common_path('plugins/Comet/jquery.comet.js')), + $scripts = array('jquery.comet.js', 'json2.js', 'updatetimeline.js'); + + foreach ($scripts as $script) { + $action->element('script', array('type' => 'text/javascript', + 'src' => common_path('plugins/Comet/'.$script)), ' '); + } + $action->elementStart('script', array('type' => 'text/javascript')); - $action->raw("var _timelineServer = \"$this->server\"; ". - "var _timeline = \"$timeline\";"); + $action->raw("$(document).ready(function() { updater.init(\"$this->server\", \"$timeline\");});"); $action->elementEnd('script'); - $action->element('script', array('type' => 'text/javascript', - 'src' => common_path('plugins/Comet/updatetimeline.js')), - ' '); + return true; } @@ -96,21 +100,17 @@ class CometPlugin extends Plugin $json = $this->noticeAsJson($notice); - $this->log(LOG_DEBUG, "JSON = '$json'"); - // Bayeux? Comet? Huh? These terms confuse me $bay = new Bayeux($this->server); foreach ($timelines as $timeline) { $this->log(LOG_INFO, "Posting notice $notice->id to '$timeline'."); $bay->publish($timeline, $json); - $this->log(LOG_DEBUG, "Done posting notice $notice->id to '$timeline'."); } $bay = NULL; } - $this->log(LOG_DEBUG, "All done."); return true; } -- cgit v1.2.3-54-g00ecf