AnsweredAssumed Answered

On Affliation change using MucAdmin() gives forbidden(403) Error in asmack android

Question asked by pooja on Dec 22, 2015

when I call following method at time of leave group gives forbidden(403) Error,How to solve this Error and set admin affliation none in muc.

 

private void changeAffiliationByOwner(String jid, String affiliation,String grpnm) throws XMPPException {

         MUCAdmin iq = new MUCAdmin();

         iq.setTo(grpnm + "@conference." + Utils.SERVER_NAME);

         iq.setType(IQ.Type.SET);

        

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

         // Set the new affiliation.

         MUCAdmin.Item item = new MUCAdmin.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.

         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());

         }

     }

Outcomes