Ejemplo n.º 1
0
 /**
  * Handles failed authentication
  */
 private function attachAuthFailureListener()
 {
     $this->client->add_cb('on_auth_failure', function ($reason) {
         $this->getContainer()->get('logger')->alert(sprintf('Received an Auth Failure: %s', $reason));
         $this->client->send_end_stream();
     });
 }
Ejemplo n.º 2
0
$client = new JAXL(array('jid' => $argv[1], 'pass' => $argv[2], 'log_level' => JAXL_INFO));
$client->require_xep(array('0045', '0203'));
//
// add necessary event callbacks here
//
$_room_full_jid = $argv[3] . "/" . $argv[4];
$room_full_jid = new XMPPJid($_room_full_jid);
$client->add_cb('on_auth_success', function () {
    global $client, $room_full_jid;
    _info("got on_auth_success cb, jid " . $client->full_jid->to_string());
    // join muc room
    $client->xeps['0045']->join_room($room_full_jid);
});
$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_groupchat_message', function ($stanza) {
    global $client;
    $from = new XMPPJid($stanza->from);
    $delay = $stanza->exists('delay', NS_DELAYED_DELIVERY);
    if ($from->resource) {
        echo "message stanza rcvd from " . $from->resource . " saying... " . $stanza->body . ($delay ? ", delay timestamp " . $delay->attrs['stamp'] : ", timestamp " . gmdate("Y-m-dTH:i:sZ")) . PHP_EOL;
    } else {
        $subject = $stanza->exists('subject');
        if ($subject) {
            echo "room subject: " . $subject->text . ($delay ? ", delay timestamp " . $delay->attrs['stamp'] : ", timestamp " . gmdate("Y-m-dTH:i:sZ")) . PHP_EOL;
        }
    }
});
Ejemplo n.º 3
0
                }
            } catch (Exception $e) {
                echo "Excepition in DialEvent: {$e}\n";
            }
        }
    }
});
// register_tick_function(array($pamiClient, 'process'));
$db = new Database();
$astdb = new AsteriskDB();
$xmpp_client = new JAXL(array('jid' => 'pbx', 'pass' => '123456', 'host' => 'avanpbx:5222'));
$xmpp_client->require_xep(array('0199'));
$connected = true;
$xmpp_client->add_cb('on_auth_failure', function ($reason) {
    global $xmpp_client;
    $xmpp_client->send_end_stream();
    _info("CALLBACK! got on_auth_failure cb with reason {$reason}");
});
$xmpp_client->add_cb('on_connect_error', function ($reason) {
    _info("connect error {$reason}");
});
$xmpp_client->add_cb('on_auth_success', function () {
    _info("connected!!");
    global $xmpp_client;
    $xmpp_client->set_status("available!", "dnd", 10);
});
$xmpp_client->add_cb('on_disconnect', function () {
    _info("disconnected!!");
    // _info("reconnecting");
    // global $xmpp_client;
    // $xmpp_client->con();
//
require_once 'jaxl.php';
$comp = new JAXL(array('jid' => $argv[1], 'pass' => $argv[2], 'host' => @$argv[3], 'port' => $argv[4], 'log_level' => JAXL_INFO));
//
// XEP's required (required)
//
$comp->require_xep(array('0114'));
//
// add necessary event callbacks here
//
$comp->add_cb('on_auth_success', function () {
    _info("got on_auth_success cb");
});
$comp->add_cb('on_auth_failure', function ($reason) {
    global $comp;
    $comp->send_end_stream();
    _info("got on_auth_failure cb with reason {$reason}");
});
$comp->add_cb('on_chat_message', function ($stanza) {
    global $comp;
    // echo back incoming message stanza
    $stanza->to = $stanza->from;
    $stanza->from = $comp->jid->to_string();
    $comp->send($stanza);
});
$comp->add_cb('on_disconnect', function () {
    _info("got on_disconnect cb");
});
//
// finally start configured xmpp stream
//