a simpler implementation of socket interface for different platform #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题:
因为要优化 socket 连接问题,发现 socket 的抽象不太好。
之前使用了 SocketWrapper 来包装不同平台的 socket 实现。即使是 web 平台也把 WebSocket 包装了一层,完全没有必要。
解决方案:
把 SocketWrapper 抽象为接口,并且和浏览器的 WebSocket API 保持一致。其他平台来适配 WebSocket API,浏览器端保持不变。
其他
抽象了 EventEmitter,有很多地方用到。这次只应用在 MPSocket,其他地方后面再说。