2008-04-02 08:09:28 +01:00
|
|
|
<?php
|
2008-04-28 23:05:31 +01:00
|
|
|
|
|
|
|
// activate full error reporting
|
|
|
|
error_reporting(E_ALL & E_STRICT);
|
|
|
|
|
2008-05-01 15:29:33 +01:00
|
|
|
include("XMPPHP/XMPP.php");
|
|
|
|
//$conn = new XMPPHP_XMPP('talk.google.com', 5222, 'user', 'password', 'xmpphp', 'gmail.com', $printlog=true, $loglevel=Logging::LEVEL_INFO);
|
|
|
|
$conn = new XMPPHP_XMPP('jabber.wentz.it', 5222, 'dev', 'd3vd3v', 'xmpphp', 'jabber.wentz.it', $printlog=true, $loglevel=XMPPHP_Log::LEVEL_VERBOSE);
|
2008-04-02 08:09:28 +01:00
|
|
|
$conn->connect();
|
2008-05-01 15:29:33 +01:00
|
|
|
while(!$conn->isDisconnected()) {
|
2008-04-02 08:09:28 +01:00
|
|
|
$payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
|
|
|
|
foreach($payloads as $event) {
|
|
|
|
$pl = $event[1];
|
|
|
|
switch($event[0]) {
|
|
|
|
case 'message':
|
|
|
|
print "---------------------------------------------------------------------------------\n";
|
|
|
|
print "Message from: {$pl['from']}\n";
|
|
|
|
if($pl['subject']) print "Subject: {$pl['subject']}\n";
|
|
|
|
print $pl['body'] . "\n";
|
|
|
|
print "---------------------------------------------------------------------------------\n";
|
|
|
|
$conn->message($pl['from'], $body="Thanks for sending me \"{$pl['body']}\".", $type=$pl['type']);
|
|
|
|
if($pl['body'] == 'quit') $conn->disconnect();
|
|
|
|
if($pl['body'] == 'break') $conn->send("</end>");
|
|
|
|
break;
|
|
|
|
case 'presence':
|
|
|
|
print "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
|
|
|
|
break;
|
|
|
|
case 'session_start':
|
2008-05-01 15:29:33 +01:00
|
|
|
print "Session Start\n";
|
2008-04-02 08:09:28 +01:00
|
|
|
$conn->presence($status="Cheese!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|