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的onMessage方法中是否有办法知道客户端发送的消息是text类型还是binary类型? #1076

Open
javalaw opened this issue Dec 27, 2024 · 1 comment

Comments

@javalaw
Copy link

javalaw commented Dec 27, 2024

$worker->onMessage = function(TcpConnection $connection, $data)
{
      //$data是text还是binary
}

js中的websocket接口可以根据data是string还是array buffer来判断,不过php中都是string。
有些场景下需要根据数据类型处理不同的业务逻辑,我看到Workerman\Protocols\Websocket里面是解析了opcode的,但似乎并没有暴露出来。

@walkor
Copy link
Owner

walkor commented Dec 28, 2024

没有暴露

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