Giter Club home page Giter Club logo

Comments (8)

kong-jing avatar kong-jing commented on June 22, 2024

boolean isConnected = mWebSocketInfo.getWebSocket().send("");
现在我使用这个来获取连接状态

from rxwebsocket.

dhhAndroid avatar dhhAndroid commented on June 22, 2024

@kong-jing 你好,感谢你反馈bug,新版本我已经修复这个问题,请使用1.5.0版本.判断WebSocket连接状态还是用那个webSocketInfo.isOpen(),这个东西只有在WebSocket在开启的时候发送一个true,其他情况都是false.
另外项目封装了WebSocketSubscriber和WebSocketAction1,你可以仿照这两个进行扩展.点击查看WebSocketSubscriber用法
点击查看WebSocketAction1用法

from rxwebsocket.

dhhAndroid avatar dhhAndroid commented on June 22, 2024

@kong-jing 你试一下效果,给我反馈一下,谢谢!

from rxwebsocket.

kong-jing avatar kong-jing commented on June 22, 2024

我试试
换了new WebSocketSubscriber() {这个扩展,webSocketInfo.isOpen()这个暂时没用了,确实是只有发送信息给客户端之后成功打开连接了才会发送true,只要接收到了onMessage ,则会变成false。
之前是在测试下websocket断网情况下webSocketInfo.isOpen()的值,通过这个来进行提示。

不知道是否和 okhttp3 一样websocket,会有请求失败的状态okhttp3
@dhhAndroid

from rxwebsocket.

dhhAndroid avatar dhhAndroid commented on June 22, 2024

@kong-jing 你指的是连接失败,还是发送失败?这个库底层就是okhttp的WebSocket实现的.不过官方的demo很老了,我用的最新的okhttp3.9.0写的.这个库,Observable下游是接收不到WebSocket连接失败的事件的,因为连接失败的话上游就做了重连处理.把错误吃掉了.

from rxwebsocket.

kong-jing avatar kong-jing commented on June 22, 2024

@dhhAndroid 我指的是类似网络中断或者后台服务挂掉导致 websocket 断开的情况,只是想在这个情况发生后得到通知。嗯,了解了,看来下游拿不到这个事件。

from rxwebsocket.

dhhAndroid avatar dhhAndroid commented on June 22, 2024

@kong-jing 我就是在异常断开的时候,重连的。你是想拿到这个错误通知吗?我改下就能实现。

from rxwebsocket.

kong-jing avatar kong-jing commented on June 22, 2024

@dhhAndroid 嗯,我想拿到这个。

from rxwebsocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.