code: func (cli *Client) handleSUBACK(p packet.Packet) error {
  	// Lock for update.
  	cli.muConn.Lock()
  	cli.muSess.Lock()
  
  	// Unlock.
  	defer cli.muConn.Unlock()
  	defer cli.muSess.Unlock()
  
  	// Extract the Packet Identifier of the Packet.
  	id := p.(*packet.SUBACK).PacketID
  
  	// Validate the Packet Identifier.
  	if err := cli.validatePacketID(cli.sess.sendingPackets, id, packet.TypeSUBSCRIBE); err != nil {
  		return err
  	}
  
  	// Get the subscription requests of the SUBSCRIBE Packet.
  	subreqs := cli.sess.sendingPackets[id].(*packet.SUBSCRIBE).SubReqs
  
  	// Delete the SUBSCRIBE Packet from the Session.
  	delete(cli.sess.sendingPackets, id)
  
  	// Get the Return Codes of the SUBACK Packet.
  	returnCodes := p.(*packet.SUBACK).ReturnCodes
  
  	// Check the lengths of the Return Codes.
  	if len(returnCodes) != len(subreqs) {
  		return ErrInvalidSUBACK
  	}
  
  	// Set the subscriptions to the Network Connection.
  	for i, code := range returnCodes {
  		// Skip if the Return Code is failure.
  		if code == packet.SUBACKRetFailure {
  			continue
  		}
  
  		// Get the Topic Filter.
  		topicFilter := string(subreqs[i].TopicFilter)
  
  		// Move the subscription information from
  		// unackSubs to ackedSubs.
  		cli.conn.ackedSubs[topicFilter] = cli.conn.unackSubs[topicFilter]
  		delete(cli.conn.unackSubs, topicFilter)
  	}
  
  	return nil
  }
docs: // handleSUBACK handles the SUBACK Packet.