import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -19,9 +19,6 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Wildfire_Exception */
require_once 'Zend/Wildfire/Exception.php';
/** Zend_Wildfire_Plugin_Interface */
require_once 'Zend/Wildfire/Plugin/Interface.php';
@ -33,7 +30,7 @@ require_once 'Zend/Json.php';
/**
* Encodes messages into the Wildfire JSON Stream Communication Protocol.
*
*
* @category Zend
* @package Zend_Wildfire
* @subpackage Protocol
@ -58,10 +55,10 @@ class Zend_Wildfire_Protocol_JsonStream
* @var array
*/
protected $_plugins = array();
/**
* Register a plugin that uses this protocol
*
*
* @param Zend_Wildfire_Plugin_Interface $plugin The plugin to be registered
* @return boolean Returns TRUE if plugin was registered, false if it was already registered
*/
@ -76,7 +73,7 @@ class Zend_Wildfire_Protocol_JsonStream
/**
* Record a message with the given data in the given structure
*
*
* @param Zend_Wildfire_Plugin_Interface $plugin The plugin recording the message
* @param string $structure The structure to be used for the data
* @param array $data The data to be recorded
@ -85,40 +82,40 @@ class Zend_Wildfire_Protocol_JsonStream
public function recordMessage(Zend_Wildfire_Plugin_Interface $plugin, $structure, $data)
{
if(!isset($this->_messages[$structure])) {
$this->_messages[$structure] = array();
$this->_messages[$structure] = array();
}
$uri = $plugin->getUri();
if(!isset($this->_messages[$structure][$uri])) {
$this->_messages[$structure][$uri] = array();
$this->_messages[$structure][$uri] = array();
}
$this->_messages[$structure][$uri][] = $this->_encode($data);
return true;
}
/**
* Remove all qued messages
*
*
* @param Zend_Wildfire_Plugin_Interface $plugin The plugin for which to clear messages
* @return boolean Returns TRUE if messages were present
*/
public function clearMessages(Zend_Wildfire_Plugin_Interface $plugin)
{
$uri = $plugin->getUri();
$present = false;
foreach ($this->_messages as $structure => $messages) {
if(!isset($this->_messages[$structure][$uri])) {
continue;
}
$present = true;
unset($this->_messages[$structure][$uri]);
if (!$this->_messages[$structure]) {
unset($this->_messages[$structure]);
}
@ -128,7 +125,7 @@ class Zend_Wildfire_Protocol_JsonStream
/**
* Get all qued messages
*
*
* @return mixed Returns qued messages or FALSE if no messages are qued
*/
public function getMessages()
@ -152,7 +149,7 @@ class Zend_Wildfire_Protocol_JsonStream
/**
* Retrieves all formatted data ready to be sent by the channel.
*
*
* @param Zend_Wildfire_Channel_Interface $channel The instance of the channel that will be transmitting the data
* @return mixed Returns the data to be sent by the channel.
* @throws Zend_Wildfire_Exception
@ -160,19 +157,20 @@ class Zend_Wildfire_Protocol_JsonStream
public function getPayload(Zend_Wildfire_Channel_Interface $channel)
{
if (!$channel instanceof Zend_Wildfire_Channel_HttpHeaders) {
throw new Zend_Wildfire_Exception('The '.get_class($channel).' channel is not supported by the '.get_class($this).' protocol.');
require_once 'Zend/Wildfire/Exception.php';
throw new Zend_Wildfire_Exception('The '.get_class($channel).' channel is not supported by the '.get_class($this).' protocol.');
}
if ($this->_plugins) {
foreach ($this->_plugins as $plugin) {
$plugin->flushMessages(self::PROTOCOL_URI);
}
}
if (!$this->_messages) {
return false;
}
$protocol_index = 1;
$structure_index = 1;
$plugin_index = 1;
@ -181,19 +179,19 @@ class Zend_Wildfire_Protocol_JsonStream
$payload = array();
$payload[] = array('Protocol-'.$protocol_index, self::PROTOCOL_URI);
foreach ($this->_messages as $structure_uri => $plugin_messages ) {
$payload[] = array($protocol_index.'-Structure-'.$structure_index, $structure_uri);
foreach ($plugin_messages as $plugin_uri => $messages ) {
$payload[] = array($protocol_index.'-Plugin-'.$plugin_index, $plugin_uri);
foreach ($messages as $message) {
$parts = explode("\n",chunk_split($message, 5000, "\n"));
for ($i=0 ; $i<count($parts) ; $i++) {
$part = $parts[$i];
@ -216,9 +214,10 @@ class Zend_Wildfire_Protocol_JsonStream
$msg);
$message_index++;
if ($message_index > 99999) {
throw new Zend_Wildfire_Exception('Maximum number (99,999) of messages reached!');
require_once 'Zend/Wildfire/Exception.php';
throw new Zend_Wildfire_Exception('Maximum number (99,999) of messages reached!');
}
}
}