Пример #1
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     // Delete activities
     foreach ($this->juliet->getActivities($this->julietJID) as $activity) {
         $this->juliet->deleteActivity($activity->id);
     }
     foreach ($this->alice->getActivities($this->aliceJID) as $activity) {
         $this->alice->deleteActivity($activity->id);
     }
     foreach ($this->romeo->getActivities($this->romeoJID) as $activity) {
         $this->romeo->deleteActivity($activity->id);
     }
     $this->alice->disconnect();
     $this->juliet->disconnect();
     $this->romeo->disconnect();
     $this->deleteUser('testalice', 'secretAlice');
     // TODO Workaround because of testRemove()
     try {
         $this->deleteUser('testjuliet', 'secretJuliet');
     } catch (\Exception $e) {
     }
     $this->deleteUser('testromeo', 'secretRomeo');
 }
Пример #2
0
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();
                }
                if ($pl['body'] == 'break') {
                    $xmpp->send("</end>");
                }
                break;
            case 'presence':
                echo "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
                break;
            case 'session_start':
                $xmpp->presence('Ready to roxorz!');
                break;
        }
    }
}
unset($xmpp);
Пример #3
0
                    }
                    if (!trim($pl['body']) || !$processing) {
                        break;
                    }
                    if ($pl['from'] === "*****@*****.**") {
                        $message = explode("\n", $pl['body']);
                        $user = trim(str_replace(array('Direct from', ':'), '', $message[0]));
                        $command = trim($message[1]);
                    } else {
                        $user = explode('/', $pl['from']);
                        $user = $user[0];
                        $command = $pl['body'];
                    }
                    $dispatch_args = json_encode(array('user' => $user, 'command' => $command));
                    $dispatch = dirname(__FILE__) . "/dispatch.php '{$dispatch_args}'";
                    DEBUG ? print `{$dispatch}` : `{$dispatch}`;
                    break;
            }
        }
    }
    if ($transfer_pending) {
        $conn->disconnect();
    } elseif ($conn->disconnected) {
        connect();
    }
    if ($first_daemon) {
        $conn->presence(DAEMON_LISTENING);
        $first_daemon = false;
        $processing = true;
    }
}
 /**
  * @return void
  */
 public function execute()
 {
     $this->connection->disconnect();
 }