@@ 111-127 (lines=17) @@ | ||
108 | * |
|
109 | * @return PromiseAdapter |
|
110 | */ |
|
111 | public function subscribe($topicName, callable $callback, $options = null) |
|
112 | { |
|
113 | $this->on($topicName, $callback); |
|
114 | ||
115 | $futureResult = new Deferred(); |
|
116 | ||
117 | $this->subscriptions[$topicName] = $futureResult; |
|
118 | $this->subscribing[$topicName] = new SubscribeMessage( |
|
119 | count($this->subscriptions), |
|
120 | (object) $options, |
|
121 | $topicName |
|
122 | ); |
|
123 | ||
124 | return $this->createPromiseAdapter( |
|
125 | $futureResult->promise() |
|
126 | ); |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * Trigger a SUBSCRIBED message for given topic. |
|
@@ 231-247 (lines=17) @@ | ||
228 | * |
|
229 | * @return PromiseAdapter |
|
230 | */ |
|
231 | public function register($procedureName, callable $callback, $options = null) |
|
232 | { |
|
233 | $this->procedures[$procedureName] = $callback; |
|
234 | ||
235 | $futureResult = new Deferred(); |
|
236 | ||
237 | $this->registrations[$procedureName] = $futureResult; |
|
238 | $this->registering[$procedureName] = new RegisterMessage( |
|
239 | count($this->registering), |
|
240 | $options, |
|
241 | $procedureName |
|
242 | ); |
|
243 | ||
244 | return $this->createPromiseAdapter( |
|
245 | $futureResult->promise() |
|
246 | ); |
|
247 | } |
|
248 | ||
249 | /** |
|
250 | * Trigger a REGISTERED message for given procedure. |