Skip to content

Commit

Permalink
Improved onSubscribe event.
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Aug 10, 2016
1 parent 3b524e5 commit 8776619
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Hprose/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* *
* hprose service class for php 5.3+ *
* *
* LastModified: Aug 8, 2016 *
* LastModified: Aug 10, 2016 *
* Author: Ma Bingyao <[email protected]> *
* *
\**********************************************************/
Expand Down Expand Up @@ -1066,10 +1066,12 @@ public function publish($topic, array $options = array()) {
$topics[$id]->messages = new SplQueue();
$topics[$id]->count = 1;
$topics[$id]->heartbeat = $heartbeat;
$onSubscribe = $self->onSubscribe;
if (is_callable($onSubscribe)) {
call_user_func($onSubscribe, $topic, $id, $self);
}
$this->timer->setImmediate(function() use ($self, $topic, $id) {
$onSubscribe = $self->onSubscribe;
if (is_callable($onSubscribe)) {
call_user_func($onSubscribe, $topic, $id, $self);
}
});
}
if (isset($topics[$id]->request)) {
$topics[$id]->request->reject(new InvalidRequestException());
Expand Down

0 comments on commit 8776619

Please sign in to comment.