public function push($name, $message, $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0)
{
if ($success !== null || $failure !== null || $cancel !== null) {
return $this->pushRequest($name, $message, $flags, $success, $failure, $cancel, $timeout);
}
return $this->pushAsync($name, $message, $flags);
}
/** * @param mixed $data * @param LoopInterface $loop * @return ChannelInterface */ public function createChannel($data, LoopInterface $loop) { $name = $data['config']['id']; $model = (new ReflectionClass($data['class']))->newInstance($loop, $data['config']); $router = new RouterComposite(['input' => $input = new Router(), 'output' => $output = new Router()]); $encoder = new Encoder(new JsonParser()); $channel = new Channel($name, $model, $router, $encoder, $loop); $router = $channel->getInput(); $router->addDefault(new RuleHandler(function ($params) use($channel) { $channel->pull($params['alias'], $params['protocol']); })); $router = $channel->getOutput(); $router->addDefault(new RuleHandler(function ($params) use($channel) { $channel->push($params['alias'], $params['protocol'], $params['flags'], $params['success'], $params['failure'], $params['cancel'], $params['timeout']); })); return $channel; }