protected function do_unsubscribe()
    {
        /**
         * Packet Identifier Generator
         *
         * @var PacketIdentifier $pi
         */
        static $pi = null;
        if (!$pi) {
            $pi = $this->PIG();
        }

        $msgid = $pi->next();

        # send SUBSCRIBE
        /**
         * @var Message\UNSUBSCRIBE $unsubscribeobj
         */
        $unsubscribeobj = $this->getMessageObject(Message::UNSUBSCRIBE);
        $unsubscribeobj->setMsgID($msgid);

        $unsubscribe_topics = array();
        # no need to check if topic is subscribed before unsubscribing
        foreach ($this->topics_to_unsubscribe as $tn => $topic_filter) {
            $unsubscribeobj->addTopic($topic_filter);
            unset($this->topics_to_unsubscribe[$tn]);
            $unsubscribe_topics[] = $topic_filter;
        }

        $unsubscribe_bytes_written = $this->message_write($unsubscribeobj);

        Debug::Log(Debug::DEBUG, 'unsubscribe(): bytes written=' . $unsubscribe_bytes_written);

        return array($msgid, $unsubscribe_topics);
    }