setPresence($to, 'subscribe'); } public function unsubscribe(string $from): void { $this->setPresence($from, 'unsubscribe'); } public function acceptSubscription(string $from): void { $this->setPresence($from, 'subscribed'); } public function declineSubscription(string $from): void { $this->setPresence($from, 'unsubscribed'); } protected function setPresence(string $to, string $type = "subscribe"): void { $xml = ""; $this->socket->send($xml); } /** * Set priority to current resource by default, or optional other resource tied to the * current username * @param string|null $forResource */ public function setPriority(int $value, string $forResource = null): void { $from = self::quote($this->socket->getOptions()->fullJid()); if ($forResource) { $from = $this->socket->getOptions()->getUsername() . "/$forResource"; } $priority = "{$this->limitPriority($value)}"; $xml = "{$priority}"; $this->socket->send($xml); } protected function limitPriority(int $value): int { if ($value > self::PRIORITY_UPPER_BOUND) { return self::PRIORITY_UPPER_BOUND; } elseif ($value < self::PRIORITY_LOWER_BOUND) { return self::PRIORITY_LOWER_BOUND; } return $value; } }