/**
  * @return void
  */
 protected function connectXmpp()
 {
     require_once t3lib_extMgm::extPath('caretaker', 'res/php/xmpphp/XMPPHP/XMPP.php');
     $this->connection = new XMPPHP_XMPP($this->config['host'], $this->config['port'], $this->config['user'], $this->config['password'], $this->config['resource'], $this->config['server']);
     // TODO configurable: $this->connection->useEncryption(FALSE);
     $this->connection->connect();
     $this->connection->processUntil('session_start');
 }
示例#2
0
 * 
 * Send "quit" to end the script
 */
// Test Comment for git commit
include "xmpphp/xmpp.php";
// test account information
$host = 'jabber.org';
$port = 5222;
$username = '******';
$password = '******';
$resource = 'xmpphp';
$server = null;
$xmpp = new XMPP($host, $port, $username, $password, $resource, $server, true, LOGGING_INFO);
$xmpp->connect();
while (!$xmpp->disconnected) {
    $payloads = $xmpp->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
    foreach ($payloads as $event) {
        $pl = $event[1];
        switch ($event[0]) {
            case 'message':
                echo "---------------------------------------------------------------------------------\n";
                echo "Message from: {$pl['from']}\n";
                if ($pl['subject']) {
                    echo "Subject: {$pl['subject']}\n";
                }
                echo $pl['body'] . "\n";
                echo "---------------------------------------------------------------------------------\n";
                $xmpp->message($pl['from'], "Thanks for sending me \"{$pl['body']}\".", $pl['type']);
                if ($pl['body'] == 'quit') {
                    $xmpp->disconnect();
                }
示例#3
0
define('PROCESS_TIMEOUT', 10);
define('DEBUG', true);
$conn = new XMPP(XMPP_HOST, XMPP_PORT, XMPP_USERNAME, XMPP_PASSWORD, 'trnd', XMPP_SERVER, DEBUG, LOGGING_INFO);
function connect()
{
    global $conn;
    $conn->connect();
    $conn->processUntil('session_start', PROCESS_TIMEOUT);
    return true;
}
$first_daemon = true;
$processing = false;
$awaiting_transfer = false;
$transfer_pending = false;
$magic = false;
for (connect(), $conn->presence(DAEMON_READY), $me = explode('/', $conn->fulljid); !$conn->disconnected; $evs = $conn->processUntil(array('message', 'presence'), PROCESS_TIMEOUT)) {
    if (is_array($evs)) {
        foreach ($evs as $ev) {
            $type = $ev[0];
            $pl = $ev[1];
            switch ($type) {
                case 'presence':
                    $other = explode('/', $pl['from']);
                    if (DEBUG) {
                        "\npresence: {$pl['from']} ";
                    }
                    if ($other[0] === $me[0] && @$other[1] !== $me[1]) {
                        // a sibling daemon!
                        if (DEBUG) {
                            echo "sibling! " . implode(" ", $pl);
                        }