You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 20, 2019. It is now read-only.
由于websocket不是一问一答的数据通讯,因此通过ws调用接口,要识别其执行结果,只能自行实现。
项目中在每个数据包中增加
cmdId
字段,来识别请求id,返回的执行结果中也包含此cmdId
。所有接口通过
asyncSend
发送数据时,在数据包中添加随机生成的uuid作为cmdId
,然后返回一个Promise,在Promise中设置监听此以cmdId为名的事件,然后通过ws发送数据。当执行结果返回时,识别到有cmdId
字段,则emit事件,触发Promise中的监听器,返回数据。以上为基本流程,代码中结构有些乱,结构不是很清晰,需要拆分重构。
The text was updated successfully, but these errors were encountered: