Ejemplo n.º 1
0
 public static function send($sendMessageTo, $message)
 {
     require_once 'class_Jabber.php';
     $jab = new Jabber();
     if (!is_array($sendMessageTo)) {
         $sendMessageTo = array($sendMessageTo);
     }
     new self($jab, $sendMessageTo, $message);
     if (!$jab->connect("vivid")) {
         throw new Kwf_Exception("Could not connect to the Jabber server");
     }
     $jab->execute(1, 3);
     $jab->disconnect();
 }
Ejemplo n.º 2
0
// 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);
// Note that we will not reach this point (and the execute() method will not
// return) until $jab->terminated is set to TRUE.  The execute() method simply
// loops, processing data from (and to) the Jabber server, and firing events
// (which are handled by our TestMessenger class) until we tell it to terminate.
//
// This event-based model will be familiar to programmers who have worked on
// desktop applications, particularly in Win32 environments.
// disconnect from the Jabber server
$jab->disconnect();
Ejemplo n.º 3
0
// create an instance of the Jabber class
$display_debug_info = false;
$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, -1);
// Note that we will not reach this point (and the execute() method will not
// return) until $jab->terminated is set to TRUE.  The execute() method simply
// loops, processing data from (and to) the Jabber server, and firing events
// (which are handled by our TestMessenger class) until we tell it to terminate.
//
// This event-based model will be familiar to programmers who have worked on
// desktop applications, particularly in Win32 environments.
// disconnect from the Jabber server
$jab->disconnect();