Skip to content

websocket的onMessage方法中是否有办法知道客户端发送的消息是text类型还是binary类型? #1076

@javalaw

Description

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions