From 8776619dd3da02c6b1e2ef5edc33f5f42f0d94f3 Mon Sep 17 00:00:00 2001 From: Ma Bingyao Date: Wed, 10 Aug 2016 20:33:22 +0800 Subject: [PATCH] Improved onSubscribe event. --- src/Hprose/Service.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Hprose/Service.php b/src/Hprose/Service.php index f6cbe0e1..753ef4f1 100644 --- a/src/Hprose/Service.php +++ b/src/Hprose/Service.php @@ -14,7 +14,7 @@ * * * hprose service class for php 5.3+ * * * - * LastModified: Aug 8, 2016 * + * LastModified: Aug 10, 2016 * * Author: Ma Bingyao * * * \**********************************************************/ @@ -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());