public function then(callable $onFulfilled = null, callable $onRejected = null)
{
if (null !== $this->result) {
return $this->result()->then($onFulfilled, $onRejected);
}
if (null === $this->canceller) {
return new static($this->resolver($onFulfilled, $onRejected));
}
$this->requiredCancelRequests++;
return new static($this->resolver($onFulfilled, $onRejected), function () {
if (++$this->cancelRequests < $this->requiredCancelRequests) {
return;
}
$this->cancel();
});
}
/** * Handle on session start * * @param \Thruway\AbstractSession $session * @param \Thruway\Transport\TransportInterface $transport */ public function onSessionStart($session, $transport) { $this->thePromise->then(function () use($session) { $this->getCaller()->call($session, 'com.example.thefunction0', [])->then(function ($res) { var_dump($res); }); }); }