示例#1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $iniFilename = 'rposwwebclient_test.ini';
     $iniContent = file_get_contents($iniFilename, FILE_USE_INCLUDE_PATH);
     if (false === $iniContent) {
         throw new \Exception("Loading .ini file '{$iniFilename}' failed.");
     }
     // Parse ini content
     $this->ini = parse_ini_string($iniContent, true);
     if (false === $this->ini) {
         throw new \Exception('Parsing .ini file failed.');
     }
     $this->aliceJID = "testalice@{$this->ini['testosw']['server']}";
     $this->julietJID = "testjuliet@{$this->ini['testosw']['server']}";
     $this->romeoJID = "testromeo@{$this->ini['testosw']['server']}";
     $this->xmpp = new XMPP();
     $this->xmpp->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->xmpp->login($this->ini['testosw']['adminname'], $this->ini['testosw']['adminpassword'], $this->ini['testosw']['resource']);
     $this->xmpp->addUser("testalice@{$this->ini['testosw']['server']}", 'secretAlice');
     $this->xmpp->addUser("testjuliet@{$this->ini['testosw']['server']}", 'secretJuliet');
     $this->xmpp->addUser("testromeo@{$this->ini['testosw']['server']}", 'secretRomeo');
     $this->xmpp->disconnect();
     $this->juliet = new XMPP();
     $this->juliet->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->juliet->login('testjuliet', 'secretJuliet', $this->ini['testosw']['resource']);
     $this->romeo = new XMPP();
     $this->romeo->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->romeo->login('testromeo', 'secretRomeo', $this->ini['testosw']['resource']);
     $this->alice = new XMPP();
     $this->alice->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->alice->login('testalice', 'secretAlice', $this->ini['testosw']['resource']);
 }
 /**
  * @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');
 }
示例#3
0
 * Send a Jabber IM to tpg_tester@jabber.org
 * Profit!
 * 
 * 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') {
 /**
  * send_notification
  *
  * Send notification when new order is received
  *
  * @access public
  * @return void
  */
 function send_notification($title, $message, $url = '')
 {
     if (!class_exists('XMPP_Api')) {
         include_once 'xmpp.class.php';
     }
     $webi_conf['user'] = $this->user;
     $webi_conf['pass'] = $this->pass;
     $webi_conf['host'] = $this->host;
     $webi_conf['port'] = $this->port;
     $webi_conf['domain'] = $this->domain;
     $webi_conf['logtxt'] = false;
     $webi_conf['log_file_name'] = "loggerxmpp.log";
     $webi_conf['tls_off'] = 0;
     $xmpp = new XMPP($webi_conf);
     $xmpp->connect();
     $this->add_log(__('Sending: ', 'wc_xmpp') . "\nТема: " . substr(get_bloginfo('wpurl'), 7, 999) . " " . $title . "\nСообщение: " . $message);
     try {
         $rec = explode(';', $this->rec);
         for ($i = 0; $i < count($rec); $i++) {
             $this->add_log(__('Rec: ', 'wc_xmpp') . "\n" . $rec[$i]);
             $xmpp->sendMessage($rec[$i], substr(get_bloginfo('wpurl'), 7, 999) . " " . $title . "\n" . $message);
         }
     } catch (Exception $e) {
         $this->add_log(sprintf(__('Error: Caught exception from send method: %s', 'wc_xmpp'), $e->getMessage()));
     }
 }