push() public method

public push ( $name, $message, $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, $timeout )
$success callable
$failure callable
$cancel callable
Exemplo n.º 1
0
 /**
  * @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;
 }