Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C/S 之间通讯最好使用 WebSocket 协议 #25

Closed
nekocode opened this issue Mar 16, 2018 · 4 comments
Closed

C/S 之间通讯最好使用 WebSocket 协议 #25

nekocode opened this issue Mar 16, 2018 · 4 comments

Comments

@nekocode
Copy link

nekocode commented Mar 16, 2018

目前因为 Client 端使用 Http 轮询的方式,导致 Server 端被设计为所谓的「生产者 / 消费者」模式,这其实是一个设计错误,会导致很多问题:

  • 无法主动 Push 数据给 Client,导致只能在 Server 用 Stack 来存数据,Client 主动 Pull
  • 无状态。没有对不同的 Client 做区分,导致有多个 Client 的情况下会竞争数据

建议可以改为使用 WebSocket 协议通讯。WebSocket Server 端可以用 Stetho 的实现,具体可以参考: https://github.com/nekocode/websocket-adb-forward

@Kyson
Copy link
Owner

Kyson commented Mar 16, 2018

首先非常感谢你提出这个非常棒的建议

在这个场景下,WebSocket确实是更好的选择,只是模拟http通讯的实现成本小一点,所以选了http实现,事实上当时的目的也是想把这个库尽快实现。

至于多个client的问题,目前这个库没有考虑到这一点,只是考虑了多个消费者(这个简单的server也是其中之一)的情况。

总之,很棒的建议,后面有精力的话我会进行优化:-)

@Kyson
Copy link
Owner

Kyson commented May 28, 2018

@nekocode 最近在develop分支上正在进行改工作...

@nekocode
Copy link
Author

Cool,期待!

@Kyson
Copy link
Owner

Kyson commented Jun 17, 2018

@nekocode 2.x使用websocket,多谢建议

@Kyson Kyson closed this as completed Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants