Пример #1
0
 public function onReceive($serv, $fd, $from_id, $data)
 {
     $config = Di::get('config');
     $processor_class = $config['processor'];
     $handler_class = $config['handler'];
     $handler = new $handler_class();
     $processor = new $processor_class($handler);
     $socket = new Socket();
     $socket->setHandle($fd);
     $socket->buffer = $data;
     $socket->server = $serv;
     $protocol = new Thrift\Protocol\TBinaryProtocol($socket, false, false);
     try {
         $protocol->fname = $config['name'];
         $processor->process($protocol, $protocol);
     } catch (\Exception $e) {
         Logger::write(date('Y-m-d H:i:s') . ' [' . $e->getCode() . '] ' . $e->getMessage() . PHP_EOL);
     }
 }
Пример #2
0
 public function sendMessage(\Services\HelloSwoole\Message $msg)
 {
     Logger::write('hello world' . PHP_EOL);
     return $msg->send_uid > 100 ? RetCode::SUCCESS : RetCode::ACCESS_DENY;
 }