专业IM即时通讯软件开发,值得信赖!

xmpp openfire+Smack4.3 认识ConnectionListener

openfire 云聊IM 139℃
监听ConnectionListener,可以获取连接状态的变化。
mConnection.addConnectionListener(new ConnectionListener() {

    @Override
    public void connected(XMPPConnection connection) {
        LogTool.d("connected ,isExcuLogin :" + isExcuLogin);
        mConnection = (AbstractXMPPConnection) connection; 
        //连接成功回调
    }

    @Override
    public void authenticated(XMPPConnection connection, boolean resumed) {
        LogTool.d("authenticated");
        // 登录鉴权回调
    }

    @Override
    public void connectionClosed() {
        LogTool.d("connectionClosed");
        //连接被关闭回调
    }

    @Override
    public void connectionClosedOnError(Exception e) {
        //连接被关闭出现异常回调
    }

    @Override
    public void reconnectionSuccessful() {
        LogTool.d("reconnectionSuccessful");
        // 重新连接成功回调
    }

    @Override
    public void reconnectingIn(int seconds) {
        LogTool.d("reconnectingIn");
        // 重新登录成功回调
    }

    @Override
    public void reconnectionFailed(Exception e) {
        LogTool.d("reconnectionFailed " + e.getMessage().toString());
        // 重新连接失败回调
    }

});
喜欢 (0)
仿微信聊天软件开发