Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IN XMPP getting exception not-authorized(401), while submitting the form

Tags:

java

android

xmpp

I am able to add group, but it showing 'The room is locked from entry until configuration is confirmed'. I researched but did't find any satisfactory answer. Below is the code how it getting XMPP connection and submitting the form. And while sending the form it throwing ' Not authorized exception'.

xmppConnection = connectionThread.getXMPPConnection();
    if (xmppConnection == null) {
        Application.getInstance().onError(R.string.NOT_CONNECTED);
        return;
    }
    final MultiUserChat multiUserChat;
    try {

        multiUserChat = new MultiUserChat(xmppConnection, room);
    //  setConfig(multiUserChat);

    } catch (IllegalStateException e) {
        Application.getInstance().onError(R.string.NOT_CONNECTED);
        return;
    }

//Code for submitting form.

private void setConfig(MultiUserChat multiUserChat) {

    try {
        Form form = multiUserChat.getConfigurationForm();
        Form submitForm = form.createAnswerForm();
        for (Iterator<FormField> fields = submitForm.getFields(); fields
                .hasNext();) {
            FormField field = (FormField) fields.next();
            if (!FormField.TYPE_HIDDEN.equals(field.getType())
                    && field.getVariable() != null) {
                submitForm.setDefaultAnswer(field.getVariable());
            }
        }
        submitForm.setAnswer("muc#roomconfig_publicroom", true);
        submitForm.setAnswer("muc#roomconfig_persistentroom", true);
        multiUserChat.sendConfigurationForm(submitForm);
    } catch (Exception e) {
        e.printStackTrace();
    }

}
like image 840
u_pendra Avatar asked Jun 07 '13 10:06

u_pendra


1 Answers

To get this Question answered, I just adapt your comment.

You are calling setConfig() to early. It should be called after joining the group.

like image 65
sschrass Avatar answered Nov 11 '22 16:11

sschrass