Some changes for debugging
This commit is contained in:
parent
cc317b169f
commit
221f13a10d
|
@ -43,12 +43,12 @@ if (!defined('LACONICA')) {
|
||||||
|
|
||||||
class MeteorPlugin extends Plugin
|
class MeteorPlugin extends Plugin
|
||||||
{
|
{
|
||||||
var $webserver = null;
|
public $webserver = null;
|
||||||
var $webport = null;
|
public $webport = null;
|
||||||
var $controlport = null;
|
public $controlport = null;
|
||||||
var $controlserver = null;
|
public $controlserver = null;
|
||||||
var $channelbase = null;
|
public $channelbase = null;
|
||||||
var $_socket = null;
|
protected $_socket = null;
|
||||||
|
|
||||||
function __construct($webserver=null, $webport=4670, $controlport=4671, $controlserver=null, $channelbase='')
|
function __construct($webserver=null, $webport=4670, $controlport=4671, $controlserver=null, $channelbase='')
|
||||||
{
|
{
|
||||||
|
@ -67,16 +67,14 @@ class MeteorPlugin extends Plugin
|
||||||
{
|
{
|
||||||
$timeline = null;
|
$timeline = null;
|
||||||
|
|
||||||
$this->log(LOG_DEBUG, 'got action ' . $action->trimmed('action'));
|
|
||||||
|
|
||||||
switch ($action->trimmed('action')) {
|
switch ($action->trimmed('action')) {
|
||||||
case 'public':
|
case 'public':
|
||||||
$timeline = '/timelines/public';
|
$timeline = 'timelines-public';
|
||||||
break;
|
break;
|
||||||
case 'tag':
|
case 'tag':
|
||||||
$tag = $action->trimmed('tag');
|
$tag = $action->trimmed('tag');
|
||||||
if (!empty($tag)) {
|
if (!empty($tag)) {
|
||||||
$timeline = '/timelines/tag/'.$tag;
|
$timeline = 'timelines-tag-'.$tag;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +108,7 @@ class MeteorPlugin extends Plugin
|
||||||
array('notice' => '0000000000'));
|
array('notice' => '0000000000'));
|
||||||
|
|
||||||
$action->elementStart('script', array('type' => 'text/javascript'));
|
$action->elementStart('script', array('type' => 'text/javascript'));
|
||||||
$action->raw("$(document).ready(function() { MeteorUpdater.init(\"$this->webserver\", $this->webport, \"{$this->channelbase}$timeline\", $user_id, \"$replyurl\", \"$favorurl\", \"$deleteurl\"); });");
|
$action->raw("$(document).ready(function() { MeteorUpdater.init(\"$this->webserver\", $this->webport, \"{$this->channelbase}{$timeline}\", $user_id, \"$replyurl\", \"$favorurl\", \"$deleteurl\"); });");
|
||||||
$action->elementEnd('script');
|
$action->elementEnd('script');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -118,22 +116,20 @@ class MeteorPlugin extends Plugin
|
||||||
|
|
||||||
function onEndNoticeSave($notice)
|
function onEndNoticeSave($notice)
|
||||||
{
|
{
|
||||||
$this->log(LOG_INFO, "Called for save notice.");
|
|
||||||
|
|
||||||
$timelines = array();
|
$timelines = array();
|
||||||
|
|
||||||
// XXX: Add other timelines; this is just for the public one
|
// XXX: Add other timelines; this is just for the public one
|
||||||
|
|
||||||
if ($notice->is_local ||
|
if ($notice->is_local ||
|
||||||
($notice->is_local == 0 && !common_config('public', 'localonly'))) {
|
($notice->is_local == 0 && !common_config('public', 'localonly'))) {
|
||||||
$timelines[] = '/timelines/public';
|
$timelines[] = 'timelines-public';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = $this->getNoticeTags($notice);
|
$tags = $this->getNoticeTags($notice);
|
||||||
|
|
||||||
if (!empty($tags)) {
|
if (!empty($tags)) {
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$timelines[] = '/timelines/tag/' . $tag;
|
$timelines[] = 'timelines-tag-' . $tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +137,6 @@ class MeteorPlugin extends Plugin
|
||||||
|
|
||||||
$json = json_encode($this->noticeAsJson($notice));
|
$json = json_encode($this->noticeAsJson($notice));
|
||||||
|
|
||||||
$this->log(LOG_DEBUG, $json);
|
|
||||||
|
|
||||||
$this->_connect();
|
$this->_connect();
|
||||||
|
|
||||||
foreach ($timelines as $timeline) {
|
foreach ($timelines as $timeline) {
|
||||||
|
@ -155,28 +149,30 @@ class MeteorPlugin extends Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _connect()
|
protected function _connect()
|
||||||
{
|
{
|
||||||
|
$controlserver = (empty($this->controlserver)) ? $this->webserver : $this->controlserver;
|
||||||
// May throw an exception.
|
// May throw an exception.
|
||||||
$this->_socket = @stream_socket_client("tcp://{$this->controlserver}:{$this->controlport}",
|
$this->_socket = stream_socket_client("tcp://{$controlserver}:{$this->controlport}");
|
||||||
$errno, $errstr, $timeout, $conflag);
|
|
||||||
if (!$this->_socket) {
|
if (!$this->_socket) {
|
||||||
throw new Exception("Couldn't connect to {$this->controlserver} on {$this->controlport}");
|
throw new Exception("Couldn't connect to {$controlserver} on {$this->controlport}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _addMessage($channel, $message)
|
protected function _addMessage($channel, $message)
|
||||||
{
|
{
|
||||||
$cmd = "ADDMESSAGE {$this->channelbase}$channel $message\n";
|
$cmd = "ADDMESSAGE {$this->channelbase}{$channel} $message\n";
|
||||||
$this->log(LOG_DEBUG, $cmd);
|
$cnt = fwrite($this->_socket, $cmd);
|
||||||
@fwrite($this->_socket, "COMMAND: $cmd");
|
|
||||||
$result = fgets($this->_socket);
|
$result = fgets($this->_socket);
|
||||||
$this->log(LOG_DEBUG, "RESULT: $result");
|
if (preg_match('/^ERR (.*)$/', $result, $matches)) {
|
||||||
|
throw new Exception('Error adding meteor message "'.$matches[1].'"');
|
||||||
|
}
|
||||||
// TODO: parse and deal with result
|
// TODO: parse and deal with result
|
||||||
}
|
}
|
||||||
|
|
||||||
function _disconnect()
|
protected function _disconnect()
|
||||||
{
|
{
|
||||||
|
$cnt = fwrite($this->_socket, "QUIT\n");
|
||||||
@fclose($this->_socket);
|
@fclose($this->_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ var MeteorUpdater = function()
|
||||||
id = message.data.id;
|
id = message.data.id;
|
||||||
|
|
||||||
// Don't add it if it already exists
|
// Don't add it if it already exists
|
||||||
|
//
|
||||||
if ($("#notice-"+id).length > 0) {
|
if ($("#notice-"+id).length > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user