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':
                    print "Session Start\n";
                    $conn->getRoster();
                    $conn->presence($status = "Cheese!");
                    break;
            }
        }
    }
} catch (XMPPHP_Exception $e) {
    die($e->getMessage());
}
                    if (isset($subject)) {
                        echo "Subject: {$subject}";
                    }
                    echo $body;
                    echo str_repeat('-', 80);
                    $cmd = explode(' ', $body);
                    $body = "Mi no entender! '{$body}'";
                    $conn->message($from, $body, $type);
                    if (isset($cmd[0])) {
                        if ($cmd[0] == 'quit') {
                            $conn->disconnect();
                        }
                        if ($cmd[0] == 'break') {
                            $conn->send('</end>');
                        }
                    }
                    break;
                case 'presence':
                    echo "Presence: {$from} [{$show}] {$status}\n";
                    break;
                case 'session_start':
                    echo "Session start\n";
                    $conn->getRoster();
                    $conn->presence('Quasar!');
                    break;
            }
        }
    }
} catch (XMPPHP_Exception $e) {
    die($e->getMessage());
}