关于使用MucAdmin()的Affliation更改在asmack android中给出了禁止(403)错误

时间:2015-12-22 14:30:04

标签: android xmpp asmack

首先我通过revokeOwnership()nad向管理员更改所有者的关联,而不是尝试revokeAdmin(),但它不起作用,而不是我尝试将方法更改为admin affliation to none

当我在离开组时给出以下方法调用禁止(403)错误,如何解决此错误并在muc中设置admin affliation none。

private void changeAffiliationByAdmin(String jid, String affiliation,String grpnm) throws XMPPException 
{
         MUCAdmin iq = new MUCAdmin();
         iq.setTo(grpnm + "@conference." + Utils.SERVER_NAME);
         iq.setType(IQ.Type.SET);


         MUCAdmin.Item item = new MUCAdmin.Item(affiliation,null);
         item.setJid(jid + "@" + Utils.SERVER_NAME);
         iq.addItem(item);

         // Wait for a response packet back from the server.
         filter = new PacketIDFilter(iq.getPacketID());
         PacketCollector response = connection.createPacketCollector(filter);
         // Send the change request to the server.


         connection.sendPacket(iq);
         // Wait up to a certain number of seconds for a reply.
         MUCAdmin answer = (MUCAdmin) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
         // Stop queuing results
         response.cancel();


         if (answer == null) {
             throw new XMPPException("No response from server.");
         }
         else if (answer.getError() != null) {
             throw new XMPPException(answer.getError());
         }
     }

如果我使用此代码更改所有者的归属,而不是没有工作,

MUCOwner iq = new   MUCOwner();
        iq.setTo(grpnm + "@conference." + Utils.SERVER_NAME);
        iq.setType(IQ.Type.SET);

        System.out.println("before affliation changed" + jid + grpnm);
        // Set the new affiliation.
          MUCOwner.Item item = new  MUCOwner.Item(affiliation,null);
        item.setJid(jid + "@" + Utils.SERVER_NAME);
        iq.addItem(item);

        System.out.println("after affliation changed" + jid + grpnm);

        // Wait for a response packet back from the server.
        filter = new PacketIDFilter(iq.getPacketID());
        PacketCollector response = connection.createPacketCollector(filter);
        // Send the change request to the server.

        System.out.println("call IQ packet" + jid + grpnm);
        connection.sendPacket(iq);
        // Wait up to a certain number of seconds for a reply.
          IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
        // Stop queuing results
        response.cancel();

        if (answer == null) {
            throw new XMPPException("No response from server.");
        }
        else if (answer.getError() != null) {
            throw new XMPPException(answer.getError());
        }

0 个答案:

没有答案