PHPDaemon\Clients\XMPP\Connection::presence PHP Method

presence() public method

Set Presence
public presence ( string $status = null, string $show = 'available', string $to = null, string $type = 'available', integer $priority )
$status string
$show string
$to string
$type string
$priority integer
    public function presence($status = null, $show = 'available', $to = null, $type = 'available', $priority = 0)
    {
        if ($type === 'available') {
            $type = '';
        }
        $to = htmlspecialchars($to);
        $status = htmlspecialchars($status);
        $show = htmlspecialchars($show);
        $type = htmlspecialchars($type);
        $priority = htmlspecialchars($priority);
        if ($show === 'unavailable') {
            $type = 'unavailable';
        }
        $out = "<presence";
        $out .= ' from="' . $this->fulljid . '"';
        if ($to) {
            $out .= ' to="' . $to . '"';
        }
        if ($type) {
            $out .= ' type="' . $type . '"';
        }
        $inner = '';
        if ($show !== 'available') {
            $inner .= "<show>{$show}</show>";
        }
        if ($status) {
            $inner .= "<status>{$status}</status>";
        }
        if ($priority) {
            $inner .= "<priority>{$priority}</priority>";
        }
        if ($inner === '') {
            $out .= "/>";
        } else {
            $out .= '>' . $inner . '</presence>';
        }
        $this->sendXML($out);
    }