* everything working
git-svn-id: svn://netflint.net/xmpphp@7 ef36c318-a008-4979-b6e8-6b496270793b
This commit is contained in:
30
cli_longrun_example.php
Normal file
30
cli_longrun_example.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
include("xmpp.php");
|
||||
$conn = new XMPP('talk.google.com', 5222, 'user', 'password', 'xmpphp', 'gmail.com', $printlog=True, $loglevel=LOGGING_VERBOSE);
|
||||
$conn->connect();
|
||||
while(!$conn->disconnected) {
|
||||
$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':
|
||||
$conn->presence($status="Cheese!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user