set_status() public méthode

public set_status ( $status, $show = 'chat', $priority = 10 )
 /**
  * Attaches the Auth Success listener
  */
 private function attachAuthSuccessListener()
 {
     $this->client->add_cb('on_auth_success', function () {
         /**
          * Set status
          */
         $this->client->set_status(self::STATUS_MESSAGE, self::STATUS, 10);
         /**
          * Join the MUC
          */
         $this->client->xeps['0045']->join_room(new \XMPPJid($this->getContainer()->get('config')['xmpp']['conference'] . '/' . $this->getContainer()->get('config')['xmpp']['nickname']));
         /**
          * Attach the stream reader. This has to be done inside a callback
          * so that JAXL's clock is already instantiated.
          */
         $this->attachStreamReader();
     });
 }
if ($argc < 3) {
    echo "Usage: {$argv['0']} jid pass\n";
    exit;
}
//
// initialize JAXL object with initial config
//
require_once 'jaxl.php';
$client = new JAXL(array('jid' => $argv[1], 'pass' => $argv[2], 'bosh_url' => 'http://*****:*****@$argv[3] ? $argv[3] : 'PLAIN', 'log_level' => JAXL_INFO));
//
// add necessary event callbacks here
//
$client->add_cb('on_auth_success', function () {
    global $client;
    _info("got on_auth_success cb, jid " . $client->full_jid->to_string());
    $client->set_status("available!", "dnd", 10);
});
$client->add_cb('on_auth_failure', function ($reason) {
    global $client;
    $client->send_end_stream();
    _info("got on_auth_failure cb with reason {$reason}");
});
$client->add_cb('on_chat_message', function ($stanza) {
    global $client;
    // echo back incoming message stanza
    $stanza->to = $stanza->from;
    $stanza->from = $client->full_jid->to_string();
    $client->send($stanza);
});
$client->add_cb('on_disconnect', function () {
    _info("got on_disconnect cb");
}
//
// add necessary event callbacks here
//
$client->add_cb('on_stream_features', function ($stanza) {
    global $client, $argv;
    $client->xeps['0077']->get_form($argv[1]);
    return "wait_for_register_form";
});
$client->add_cb('on_disconnect', function () {
    global $form;
    _info("registration " . ($form['type'] == 'result' ? 'succeeded' : 'failed'));
});
//
// finally start configured xmpp stream
//
$client->start();
//
// if registration was successful
// try to connect with newly registered account
//
if ($form['type'] == 'result') {
    _info("connecting newly registered user account");
    $client = new JAXL(array('jid' => $form['username'] . '@' . $argv[1], 'pass' => $form['password'], 'log_level' => JAXL_DEBUG));
    $client->add_cb('on_auth_success', function () {
        global $client;
        $client->set_status('Available');
    });
    $client->start();
}
echo "done\n";
Exemple #4
0
    $source = $argv[1];
    $nick = $argv[2];
} else {
    l("No identity!", L_AAAA);
    die;
}
$config['sim_prefix'] .= $nick;
l("[JAXL] Loading JAXL and connecting...");
$client = new \JAXL($config['jaxl']);
$client->require_xep(array('0045', '0203', '0199'));
$client->add_cb('on_auth_success', function () {
    global $client, $config, $rooms;
    l("[JAXL] Connected with jid " . $client->full_jid->to_string());
    $client->get_vcard();
    $client->get_roster();
    $client->set_status("", "chat", 10);
    $ctrl = new \XMPPJid($config['LCN_control'] . '/' . $config['sim_prefix']);
    l("[JAXL] Joining room " . $ctrl->to_string());
    $client->xeps['0045']->join_room($ctrl);
    l("[JAXL] Joined room " . $ctrl->to_string());
    $rooms = new \XMPPJid($config['sim'] . '/' . $config['sim_prefix']);
    l("[JAXL] Joining room " . $rooms->to_string());
    $client->xeps['0045']->join_room($rooms);
    l("[JAXL] Joined room " . $rooms->to_string());
});
$client->add_cb('on_auth_failure', function ($reason) {
    global $client;
    $client->send_end_stream();
    l("[JAXL] Auth failure: " . $reason, L_WARN);
});
// Where the magic happens. "Magic" "Happens". I dunno why I type this either.