Project

General

Profile

Get msg offline with jaxmpp3

shir Hu
Added almost 4 years ago

Hello,

After login tigase server, didn't receive msg offline with jaxmpp3. then I try to register module "FlexibleOfflineMessageRetrieval", Occur Exception as follow:

  Exception in thread "main" java.lang.NullPointerException
    at tigase.jaxmpp.core.client.xmpp.modules.flexible_offline.FlexibleOfflineMessageRetrieval.afterRegister(FlexibleOfflineMessageRetrieval.java:52)
    at tigase.jaxmpp.core.client.XmppModulesManager.initIfRequired(XmppModulesManager.java:122)
    at tigase.jaxmpp.j2se.Jaxmpp.login(Jaxmpp.java:276)
    at com.utils.UserUtil.login(UserUtil.java:118)
    at com.utils.UserUtil.main(UserUtil.java:239)

then I see the source code like this:

  @Override
    public void afterRegister() {
        PresenceModule presenceModule = context.getModuleProvider().getModule( PresenceModule.class );
        presenceModule.setInitialPresence( false );
        log.log( Level.INFO, "loaded FlexibleOfflineMessageRetrieval, disabling initial presence");
    }

So I try to register PresenceModule before register FlexibleOfflineMessageRetrieval, Occur Exception:

java.lang.RuntimeException: PresenceStore is not created!
    at tigase.jaxmpp.core.client.xmpp.modules.presence.PresenceModule.beforeRegister(PresenceModule.java:439)
    at tigase.jaxmpp.core.client.XmppModulesManager.register(XmppModulesManager.java:149)
    at com.utils.UserUtil$1.onConnected(UserUtil.java:52)
    at tigase.jaxmpp.core.client.Connector$ConnectedHandler$ConnectedEvent.dispatch(Connector.java:48)
    at tigase.jaxmpp.core.client.Connector$ConnectedHandler$ConnectedEvent.dispatch(Connector.java:1)
    at tigase.jaxmpp.core.client.eventbus.DefaultEventBus.doFire(DefaultEventBus.java:141)
    at tigase.jaxmpp.core.client.eventbus.DefaultEventBus.doFire(DefaultEventBus.java:130)
    at tigase.jaxmpp.core.client.eventbus.DefaultEventBus.fire(DefaultEventBus.java:159)
    at tigase.jaxmpp.j2se.connectors.socket.SocketConnector.fireOnConnected(SocketConnector.java:259)
    at tigase.jaxmpp.j2se.connectors.socket.SocketConnector.start(SocketConnector.java:807)
    at tigase.jaxmpp.core.client.connector.ConnectorWrapper.start(ConnectorWrapper.java:94)
    at tigase.jaxmpp.j2se.Jaxmpp.login(Jaxmpp.java:304)
    at com.utils.UserUtil.login(UserUtil.java:118)
    at com.utils.UserUtil.main(UserUtil.java:239)

then I try to set PresenceStore as follow:

 PresenceModule pm=new PresenceModule();
 PresenceStore presenceStore=pm.getPresenceStore(sessionObject) ;
 pm.setPresenceStore(jaxmpp.getSessionObject(),presenceStore);
 jaxmpp.getModulesManager().register(pm);

Also occur "PresenceStore is not created!", I have no idea how to solve this question ?


Replies (3)

(1)

Added by shir Hu almost 4 years ago

I found that if add code initialize presend before login:

  Presence.initialize(jaxmpp);

and add code sendInitialPresence() after login:

  PresenceModule presence=jaxmpp.getModulesManager().getModule(PresenceModule.class);
  presence.sendInitialPresence();

It works well now .

(1)
Avatar?id=6098&size=32x32

Added by Bartosz Malkowski TigaseTeam almost 4 years ago

Right.

After modularization of jaxmpp3, developer have to register each used in jaxmpp. You can do that before login, just after create new instance of jaxmpp.

Initial presence should be sent automatically (if Presence module is registered of course).

(1)

Added by Wojciech Kapcia TigaseTeam almost 4 years ago

shir Hu wrote:

Hello,

After login tigase server, didn't receive msg offline with jaxmpp3. then I try to register module "FlexibleOfflineMessageRetrieval", Occur Exception as follow:

In addition - please note that this is implementation of XEP-0013: Flexible Offline Message Retrieval which alters handling of retrieval of offline messages - by default, after initial presence you will automatically receive all offline messages.

    (1-3/3)