18034727885
2026-07-01 cc92004ffe05887682e71be4202bdc3552d9f44e
修复问题
1个文件已修改
31 ■■■■■ 已修改文件
rxnetty/src/main/java/cn/sinata/rxnetty/CoreService.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rxnetty/src/main/java/cn/sinata/rxnetty/CoreService.java
@@ -23,6 +23,7 @@
import io.reactivex.netty.channel.ObservableConnection;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
@@ -258,17 +259,25 @@
            return;
        }
        //reconnect
        Observable.timer(3, TimeUnit.SECONDS).subscribe(new Action1<Long>() {
            @Override
            public void call(Long aLong) {
                if (mConnection != null) {
                    mConnection.close();
                    mConnection = null;
                }
                Log.i("CoreService", "sendHeart_websocket长连接断开,重新连接");
                connectServer();
            }
        });
        Observable.timer(3, TimeUnit.SECONDS)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Long>() {
                    @Override
                    public void call(Long aLong) {
                        if (mConnection != null) {
                            mConnection.close();
                            mConnection = null;
                        }
                        Log.i("CoreService", "sendHeart_websocket长连接断开,重新连接");
                        connectServer();
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwable.printStackTrace();
                    }
                });
    }