Permalink
Browse files

Docs

  • Loading branch information...
1 parent 401072b commit ed54857526a488e65b66d8412ac20251818fc5a7 @kakserpom committed Mar 20, 2013
Showing with 64 additions and 7 deletions.
  1. +1 −2 lib/EventHandlers.php
  2. +59 −1 lib/PubSubEvent.php
  3. +1 −1 lib/RedisClient.php
  4. +1 −1 lib/RedisClientConnection.php
  5. +2 −2 lib/Request.php
View
@@ -1,5 +1,4 @@
<?php
-
/**
* Event handlers trait
*
@@ -53,4 +52,4 @@ public function unbind($event, $cb = null) {
unset($this->eventHandlers[$event][$p]);
return true;
}
-}
+}
View
@@ -9,23 +9,66 @@
*/
class PubSubEvent extends SplObjectStorage {
- public $sub = array();
+ /**
+ * Subscriptions
+ * @var array
+ */
+ public $sub = [];
+
+ /**
+ * Activation callback
+ * @var callable
+ */
public $actCb;
+
+ /**
+ * Deactivation callback
+ * @var callable
+ */
public $deactCb;
+
+ /**
+ * Constructor
+ * @return object
+ */
public function __construct() {
$this->storage = new SplObjectStorage;
}
+
+ /**
+ * Sets onActivation callback.
+ * @param callable Callback
+ * @return PubSubEvent
+ */
public function onActivation($cb) {
$this->actCb = $cb;
return $this;
}
+
+ /**
+ * Sets onDeactivation callback.
+ * @param callable Callback
+ * @return PubSubEvent
+ */
public function onDeactivation($cb) {
$this->deactCb = $cb;
return $this;
}
+
+ /**
+ * Constructor
+ * @return PubSubEvent
+ */
public static function init() {
return new static;
}
+
+ /**
+ * Subscribe
+ * @param object Subcriber object
+ * @param callable Callback
+ * @return PubSubEvent
+ */
public function sub($obj, $cb) {
$act = $this->count() === 0;
$this->attach($obj, $cb);
@@ -34,19 +77,34 @@ public function sub($obj, $cb) {
call_user_func($this->actCb, $this);
}
}
+ return $this;
}
+
+ /**
+ * Unsubscripe
+ * @param object Subscriber object
+ * @return PubSubEvent
+ */
public function unsub($obj) {
$this->detach($obj);
if ($this->count() === 0) {
if ($this->deactCb !== null) {
call_user_func($this->deactCb, $this);
}
}
+ return $this;
}
+
+ /**
+ * Publish
+ * @param mixed Data
+ * @return PubSubEvent
+ */
public function pub($data) {
foreach ($this as $obj) {
$cb = $this->getInfo();
call_user_func($cb, $data);
}
+ return $this;
}
}
View
@@ -1,7 +1,7 @@
<?php
/**
- * @package Applications
+ * @package NetworkClients
* @subpackage RedisClient
*
* @author Zorin Vasily <kak.serpom.po.yaitsam@gmail.com>
@@ -1,7 +1,7 @@
<?php
/**
- * @package Applications
+ * @package NetworkClients
* @subpackage RedisClient
*
* @author Zorin Vasily <kak.serpom.po.yaitsam@gmail.com>
View
@@ -423,8 +423,8 @@ public function finish($status = 0, $zombie = FALSE) {
}
if (!Daemon::$obInStack) { // preventing recursion
- ob_flush();
- }
+ ob_flush();
+ }
if ($status !== -1) {
$this->postFinishHandler();

0 comments on commit ed54857

Please sign in to comment.