Callback on AutoJoinOnSuccess in MucClientChatManager

I have XMPP client create/join an instant room when connected to Openfire, and it immediately calls MultiUserChat.makeInstant() (i.e. unlock the room) and sends an extended Presence protocol to the room. The client has enabled ReconnectionManager and MucClientChatManager.setAutoJoinOnReconnect(). If I restarted Openfire, all clients would be disconnected and the instant room would be deleted as expected. Although all clients reconnected to Openfire and rejoined the instant room automatically, there were no easy ways for clients to do any post-join operation (i.e. unlock the room and sending an extended Presence protocol.) I understand that the auto-join-on-reconnect feature was meant for connectivity issue, but it will be nice that it can handle server restart situation as well.

I would like to propose a small enhancement to have a callback upon auto-join-on-success:

MucClientChatManager#setAutoJoinSuccessCallback(AutoJoinSuccessCallback callback) as

    /**
     * Set a callback invoked by this manager when automatic join on reconnect success.
     * If successCallback is not <code>null</code>, automatic rejoin will also
     * be enabled.
     *
     * @param successCallback the callback
     */
    public void setAutoJoinSuccessCallback(AutoJoinSuccessCallback successCallback) {
        autoJoinSuccessCallback = successCallback;
        if (successCallback != null) {
            setAutoJoinOnReconnect(true);
        }
    }
...
public void authenticated(XMPPConnection connection, boolean resumed) {
    ....
    try {
        muc.join(nickname);
        if (successCallback != null) {
            successCallback.autoJoinSuccess(muc, nickname);
        }
    } catch (NotAMucServiceException | NoResponseException | XMPPErrorException
             | NotConnectedException | InterruptedException e) {

A new callback interface AutoJoinSuccessCallback.java:

package org.jivesoftware.smackx.muc;

import org.jxmpp.jid.parts.Resourcepart;

public interface AutoJoinSuccessCallback {

    /**
     * Invoked if the automatic rejoin rooms on reconnect success.
     *
     * @param muc the joined MultiUserChat
     * @param nickname nickname used by participant to join the room
     */
    void autoJoinSuccess(MultiUserChat muc, Resourcepart nickname);

}

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.