Пример #1
0
$xmpp->requires(array('JAXL0054', 'JAXL0206'));
function doAuth($mechanism, $xmpp)
{
    $xmpp->auth('DIGEST-MD5');
}
function postAuth($payload, $xmpp)
{
    $xmpp->JAXL0054('getVCard', false, $xmpp->jid, 'handleVCard');
}
function handleVCard($payload, $xmpp)
{
    echo "<b>Successfully fetched VCard</b><br/>";
    print_r($payload);
    $xmpp->JAXL0206('endStream');
}
function postDisconnect($payload, $xmpp)
{
    exit;
}
function postAuthFailure($payload, $xmpp)
{
    echo "OOPS! Auth failed";
}
// Register callbacks for required events
JAXLPlugin::add('jaxl_get_auth_mech', 'doAuth');
JAXLPlugin::add('jaxl_post_auth', 'postAuth');
JAXLPlugin::add('jaxl_post_auth_failure', 'postAuthFailure');
JAXLPlugin::add('jaxl_post_disconnect', 'postDisconnect');
// Fire start Jaxl in bosh mode
$xmpp->startCore('bosh');
Пример #2
0
 }
 // Add callbacks on various event handlers
 $jaxl->addPlugin('jaxl_post_auth_failure', array('boshchat', 'postAuthFailure'));
 $jaxl->addPlugin('jaxl_post_auth', array('boshchat', 'postAuth'));
 $jaxl->addPlugin('jaxl_post_disconnect', array('boshchat', 'postDisconnect'));
 $jaxl->addPlugin('jaxl_get_empty_body', array('boshchat', 'postEmptyBody'));
 $jaxl->addPlugin('jaxl_get_bosh_curl_error', array('boshchat', 'postCurlErr'));
 $jaxl->addPlugin('jaxl_get_message', array('boshchat', 'getMessage'));
 $jaxl->addPlugin('jaxl_get_presence', array('boshchat', 'getPresence'));
 $jaxl->addPlugin('jaxl_post_roster_update', array('boshchat', 'postRosterUpdate'));
 // Handle incoming bosh request
 switch ($_REQUEST['jaxl']) {
     case 'connect':
         $jaxl->user = $_POST['user'];
         $jaxl->pass = $_POST['pass'];
         $jaxl->startCore('bosh');
         break;
     case 'disconnect':
         $jaxl->JAXL0206('endStream');
         break;
     case 'getRosterList':
         $jaxl->getRosterList();
         break;
     case 'setStatus':
         $jaxl->setStatus(FALSE, FALSE, FALSE, TRUE);
         break;
     case 'message':
         $jaxl->sendMessage(BOSHCHAT_ADMIN_JID, $_POST['message']);
         break;
     case 'ping':
         $jaxl->JAXL0206('ping');
Пример #3
0
    function getPresence($payloads, $jaxl)
    {
        foreach ($payloads as $payload) {
            // print_r($payload);
        }
    }
    function postSubscriptionRequest($payload, $jaxl)
    {
        $jaxl->log("Subscription request sent to " . $payload['from']);
    }
    function postSubscriptionAccept($payload, $jaxl)
    {
        $jaxl->log("Subscription accepted by " . $payload['from']);
    }
    function getId($payload, $jaxl)
    {
        return $payload;
    }
}
// Add callbacks on various event handlers
$echobot = new echobot();
$jaxl->addPlugin('jaxl_post_auth', array($echobot, 'postAuth'));
$jaxl->addPlugin('jaxl_get_message', array($echobot, 'getMessage'));
$jaxl->addPlugin('jaxl_get_presence', array($echobot, 'getPresence'));
$jaxl->addPlugin('jaxl_post_roster_update', array($echobot, 'postRosterUpdate'));
$jaxl->addPlugin('jaxl_post_subscription_request', array($echobot, 'postSubscriptionRequest'));
$jaxl->addPlugin('jaxl_post_subscription_accept', array($echobot, 'postSubscriptionAccept'));
$jaxl->addPlugin('jaxl_get_id', array($echobot, 'getId'));
// Fire start Jaxl core
$jaxl->startCore("stream");
Пример #4
0
 * Read more: http://bit.ly/aGpYf8
 */
// Initialize Jaxl Library
require_once '../core/jaxl.class.php';
$jaxl = new JAXL(array('port' => 5559, 'compHost' => 'component.localhost', 'compPass' => '', 'logLevel' => 5));
// Include required XEP's
$jaxl->requires('JAXL0114');
// Jabber Component Protocol
// Sample Component class
class componentbot
{
    function postAuth($payload, $jaxl)
    {
        $jaxl->log("Component handshake completed ...");
    }
    function getMessage($payloads, $jaxl)
    {
        foreach ($payloads as $payload) {
            if (strlen($payload['body']) > 0) {
                $jaxl->sendMessage($payload['from'], $payload['body'], $payload['to']);
            }
        }
    }
}
// Add callbacks on various event handlers
$componentbot = new componentbot();
JAXLPlugin::add('jaxl_post_handshake', array($componentbot, 'postAuth'));
JAXLPlugin::add('jaxl_get_message', array($componentbot, 'getMessage'));
// Fire start Jaxl core
$jaxl->startCore("component");
Пример #5
0
$xmpp->requires('JAXL0054');
function postConnect($payload, $xmpp)
{
    $xmpp->startStream();
}
function doAuth($mechanism, $xmpp)
{
    $xmpp->auth('DIGEST-MD5');
}
function postAuth($payload, $xmpp)
{
    $xmpp->JAXL0054('getVCard', false, $xmpp->jid, 'handleVCard');
}
function handleVCard($payload, $xmpp)
{
    echo "<b>Successfully fetched VCard</b><br/>";
    print_r($payload);
    $xmpp->shutdown();
}
function postAuthFailure($payload, $xmpp)
{
    echo "OOPS! Auth failed";
}
// Register callbacks for required events
JAXLPlugin::add('jaxl_post_connect', 'postConnect');
JAXLPlugin::add('jaxl_get_auth_mech', 'doAuth');
JAXLPlugin::add('jaxl_post_auth', 'postAuth');
JAXLPlugin::add('jaxl_post_auth_failure', 'postAuthFailure');
// Fire start JAXL Core
$xmpp->startCore();