コード例 #1
0
function on_presence_stanza($client, $stanza)
{
    global $client;
    $type = $stanza->type ? $stanza->type : "available";
    $show = $stanza->show ? $stanza->show : "???";
    _info($stanza->from . " is now " . $type . " ({$show})");
    if ($type == "available") {
        // fetch vcard
        $client->get_vcard($stanza->from);
    }
}
function on_disconnect($client)
{
    _info("got on_disconnect cb");
}
//
// bootstrap all account instances
//
foreach ($accounts as $account) {
    $client = new JAXL(array('jid' => $account[0], 'pass' => $account[1], 'log_level' => JAXL_DEBUG));
    $client->add_cb('on_auth_success', 'on_auth_success');
    $client->add_cb('on_auth_failure', 'on_auth_failure');
    $client->add_cb('on_chat_message', 'on_chat_message');
    $client->add_cb('on_presence_stanza', 'on_presence_stanza');
    $client->add_cb('on_disconnect', 'on_disconnect');
    $client->connect($client->get_socket_path());
    $client->start_stream();
}
// start core loop
JAXLLoop::run();
echo "done\n";
コード例 #2
0
ファイル: index.php プロジェクト: akashbhikadiya3/jaxl
<?php

/* Include Key file */
include_once "config.ini.php";
/* Include JAXL Class */
include_once "jaxl.class.php";
/* Create an instance of XMPP Class */
$jaxl = new JAXL();
try {
    /* Initiate the connection */
    $jaxl->connect();
    /* Communicate with Jabber Server */
    while ($jaxl->isConnected) {
        $jaxl->getXML();
    }
} catch (Exception $e) {
    die($e->getMessage());
}
コード例 #3
0
            case 'unsubscribe':
                roster_remove($jid->node);
                send_status($stanza->to, $stanza->from, 'unsubscribed');
                break;
            case 'unavailable':
                roster_resource_set($jid->node, $jid->resource);
                break;
            case NULL:
                $status = $stanza->show ? $stanza->show : 'available';
                $message = $stanza->status;
                roster_resource_set($jid->node, $jid->resource, $status, $message);
                break;
        }
    });
    // connect to the destination host/port
    if ($comp->connect($comp->get_socket_path())) {
        $comp->emit('on_connect');
        JAXLLoop::run(2, 0);
        $comp->emit('on_disconnect');
    }
    sleep(2);
    unset($comp);
}
function manager_read()
{
    global $astman;
    $response = $astman->wait_response(true);
    $reconnects = $astman->reconnects;
    $oldsocket = $astman->socket;
    while ($response === false && $reconnects > 0) {
        $astman->disconnect();