Skip to content
This repository has been archived by the owner on Nov 20, 2019. It is now read-only.

重构asyncSend流程 #1

Open
binsee opened this issue Apr 4, 2018 · 2 comments
Open

重构asyncSend流程 #1

binsee opened this issue Apr 4, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@binsee
Copy link
Owner

binsee commented Apr 4, 2018

由于websocket不是一问一答的数据通讯,因此通过ws调用接口,要识别其执行结果,只能自行实现。

项目中在每个数据包中增加cmdId字段,来识别请求id,返回的执行结果中也包含此cmdId

所有接口通过 asyncSend发送数据时,在数据包中添加随机生成的uuid作为cmdId,然后返回一个Promise,在Promise中设置监听此以cmdId为名的事件,然后通过ws发送数据。当执行结果返回时,识别到有cmdId字段,则emit事件,触发Promise中的监听器,返回数据。

以上为基本流程,代码中结构有些乱,结构不是很清晰,需要拆分重构。

@binsee binsee added the enhancement New feature or request label Apr 4, 2018
@binsee binsee self-assigned this Apr 4, 2018
@binsee binsee added this to the 1.0 milestone Apr 5, 2018
@binsee binsee added the help wanted Extra attention is needed label Apr 8, 2018
@shiheha
Copy link

shiheha commented Jul 23, 2018

怎么联系你

@binsee
Copy link
Owner Author

binsee commented Jul 23, 2018

@shiheha #11

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants