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

WebSocket.onopen 方法在 iOS 不生效 #419

Open
ddiu8081 opened this issue Feb 14, 2023 · 1 comment · May be fixed by #420
Open

WebSocket.onopen 方法在 iOS 不生效 #419

ddiu8081 opened this issue Feb 14, 2023 · 1 comment · May be fixed by #420
Labels
bug Something isn't working Needs: Triage 🔍

Comments

@ddiu8081
Copy link

描述

前端参考 Hummer Websocket 文档示例代码,建立 Websocket 连接成功,send 方法可用,但 onOpen 方法始终无法收到回调。

Hummer version:

master branch

复现步骤

  1. 按样例代码连接 WS 服务器
  2. onopen 方法无法触发

预期结果

正常打印出 WebSocket onOpen 信息。

样例代码、屏幕截图或者仓库链接

const ws = new WebSocket('ws://x.x.x.x:8000');
ws.onopen = () => {
    console.log('WebSocket onOpen'); 
}
@ddiu8081 ddiu8081 added bug Something isn't working Needs: Triage 🔍 labels Feb 14, 2023
@ddiu8081
Copy link
Author

调试 iOS Hummer 代码发现,(void)webSocketDidOpen:(SRWebSocket *)webSocket 方法中只是执行了连接本身的一些操作,并没有去调用 self.onOpen

ScreenShot 2023-02-14 at 17 58 14

调试加上如下代码可解决:

self.onOpen ? self.onOpen(@[@{}]) : nil;

ddiu8081 added a commit to ddiu8081/Hummer that referenced this issue Feb 14, 2023
@ddiu8081 ddiu8081 linked a pull request Feb 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs: Triage 🔍
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant