| | |
| | | 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; |
| | |
| | | return; |
| | | } |
| | | //reconnect |
| | | Observable.timer(3, TimeUnit.SECONDS).subscribe(new Action1<Long>() { |
| | | Observable.timer(3, TimeUnit.SECONDS) |
| | | .subscribeOn(Schedulers.io()) |
| | | .observeOn(AndroidSchedulers.mainThread()) |
| | | .subscribe(new Action1<Long>() { |
| | | @Override |
| | | public void call(Long aLong) { |
| | | if (mConnection != null) { |
| | |
| | | Log.i("CoreService", "sendHeart_websocket长连接断开,重新连接"); |
| | | connectServer(); |
| | | } |
| | | }, new Action1<Throwable>() { |
| | | @Override |
| | | public void call(Throwable throwable) { |
| | | throwable.printStackTrace(); |
| | | } |
| | | }); |
| | | |
| | | } |