JAXL 3.关闭

时间:2012-10-18 05:55:01

标签: php xmpp

我试着通过xmpp使用jaxl 3.0进行通知。唯一的事情,我不能不知道 - 我怎么能在工作完成后关闭JAXL服务器?无法看到任何停止jaxl-server的回调

以下是我的代码的一部分

   public function __construct(JAXL $jaxl){
     $this->client=$jaxl;
     $this->client->add_cb('on_auth_success', array($this,'send'));
   }

   public function setSenders($senders){
       $this->senders=$senders;
   }
   public function addLine($messagePart){
        $this->message.=$messagePart.PHP_EOL;
   }

   public function notify(){
      $this->client->start();
   }

   public function send(){
   foreach($this->senders as $sender){
      $this->client->send_chat_msg($sender,$this->message);
    }
    //Here server should be stopped. Everything is done.
   }

1 个答案:

答案 0 :(得分:2)

您需要调用$client->send_end_stream();,其中$client是JAXL实例。这将发送xmpp流结束包。您还可以注册JAXL实例成功关闭与服务器连接时调用的on_disconnect事件的回调。有关更多详细信息,请参阅examples/echo_bot.php(它使用了这两者)。