public function message($to, $body, $type = 'chat', $subject = null, $payload = null)
{
if ($type === null) {
$type = 'chat';
}
$to = htmlspecialchars($to);
$body = htmlspecialchars($body);
$subject = htmlspecialchars($subject);
$out = '<message from="' . $this->fulljid . '" to="' . $to . '" type="' . $type . '">';
if ($subject) {
$out .= '<subject>' . $subject . '</subject>';
}
$out .= '<body>' . $body . '</body>';
if ($payload) {
$out .= $payload;
}
$out .= "</message>";
$this->sendXML($out);
}