diff options
author | Brion Vibber <brion@pobox.com> | 2010-10-05 13:25:28 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-10-05 13:25:28 -0700 |
commit | eb04df583a1a3afb4ca7de5ffd59fee4a6903210 (patch) | |
tree | 94b950c030f48a504c3208c8a287f047f0b29438 /plugins/TwitterBridge/jsonstreamreader.php | |
parent | 76353ede54edd8e99ddb9c209ff408486282c0c5 (diff) |
Buncha cleanup
Diffstat (limited to 'plugins/TwitterBridge/jsonstreamreader.php')
-rw-r--r-- | plugins/TwitterBridge/jsonstreamreader.php | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/plugins/TwitterBridge/jsonstreamreader.php b/plugins/TwitterBridge/jsonstreamreader.php index 898766357..0d16b68bd 100644 --- a/plugins/TwitterBridge/jsonstreamreader.php +++ b/plugins/TwitterBridge/jsonstreamreader.php @@ -202,13 +202,7 @@ abstract class JsonStreamReader $lines = explode(self::CRLF, $buffer); foreach ($lines as $line) { if ($this->state == 'headers') { - if ($line == '') { - $this->state = 'active'; - common_log(LOG_DEBUG, "$this->id connection is active!"); - } else { - common_log(LOG_DEBUG, "$this->id read HTTP header: $line"); - $this->responseHeaders[] = $line; - } + $this->handleLineHeaders($line); } else if ($this->state == 'active') { $this->handleLineActive($line); } @@ -219,15 +213,26 @@ abstract class JsonStreamReader { // One JSON object on each line... // Will we always deliver on packet boundaries? - $lines = explode("\n", $buffer); + $lines = explode(self::CRLF, $buffer); foreach ($lines as $line) { $this->handleLineActive($line); } } - function handleLineActive($line) + function handleLineHeaders($line) { if ($line == '') { + $this->state = 'active'; + common_log(LOG_DEBUG, "$this->id connection is active!"); + } else { + common_log(LOG_DEBUG, "$this->id read HTTP header: $line"); + $this->responseHeaders[] = $line; + } + } + + function handleLineActive($line) + { + if ($line == "") { // Server sends empty lines as keepalive. return; } @@ -235,9 +240,9 @@ abstract class JsonStreamReader if ($data) { $this->handleJson($data); } else { - common_log(LOG_ERR, "$this->id received bogus JSON data: " . $line); + common_log(LOG_ERR, "$this->id received bogus JSON data: " . var_export($line, true)); } } - abstract function handleJson(array $data); + abstract protected function handleJson(array $data); } |