Beispiel #1
0
        }
    }
    function handleDebug($msg, $level)
    {
        echo "DBG: {$msg}\n";
    }
}
// include the Jabber class
require_once "class_Jabber.php";
// create an instance of the Jabber class
$display_debug_info = true;
$jab = new Jabber($display_debug_info);
// create an instance of our event handler class
$test = new TestMessenger($jab);
// set handlers for the events we wish to be notified about
$jab->set_handler("connected", $test, "handleConnected");
$jab->set_handler("authenticated", $test, "handleAuthenticated");
$jab->set_handler("authfailure", $test, "handleAuthFailure");
$jab->set_handler("heartbeat", $test, "handleHeartbeat");
$jab->set_handler("error", $test, "handleError");
$jab->set_handler("message_normal", $test, "handleMessage");
$jab->set_handler("message_chat", $test, "handleMessage");
$jab->set_handler("debug_log", $test, "handleDebug");
$jab->set_handler("rosterupdate", $test, "handleRosterUpdate");
echo "Connecting ...\n";
// connect to the Jabber server
if (!$jab->connect(JABBER_SERVER)) {
    die("Could not connect to the Jabber server!\n");
}
// now, tell the Jabber class to begin its execution loop
$jab->execute(CBK_FREQ, RUN_TIME);