Project

General

Profile

about reconnect

Clarence Pan
Added almost 4 years ago

Dear All,

 I'm trying to develop an chatting software on android equipment, using JAXMPP 2.X . And I would like to ask you that if there are any methods provided by JAXMPP 2.X to monitor the web connect status. Because I want to reconnect to the server when the web connect status changes. Thank you!

Replies (2)

(1)

Added by Wojciech Kapcia TigaseTeam almost 4 years ago

There are events for connected/disconnected:

jaxmpp.addListener(JaxmppCore.Disconnected, new Listener<JaxmppCore.JaxmppEvent> () {

    @Override
    public void handleEvent( JaxmppCore.JaxmppEvent be ) throws JaxmppException {
        // code
    }
});

Added by Clarence Pan almost 4 years ago

I've found a method like this:

jaxmpp.getConnector().addListener(Connector.StateChanged, new Listener<Connector.ConnectorEvent>() {

            @Override
            public void handleEvent(Connector.ConnectorEvent paramAnonymousConnectorEvent) throws JaxmppException {
                // TODO Auto-generated method stub
                 state = jaxmpp.getConnector().getState();
                 if(state == State.disconnected){

                 }else{

                 }
            }

        });

But thank you also

    (1-2/2)