search

Home  >  Q&A  >  body text

javascript - The information received by WebSocket is binary. How to parse it?

I grabbed other people’s ws information and got Blob type data. How should I parse it??

天蓬老师天蓬老师2752 days ago931

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-16 13:46:39

    Although websocket is based on TCP, a protocol on the same layer as HTTP, its frame structure is indeed quite complicated, but what can be done? . .
    The following article has an introduction to the frame structure of websocket. Those who are familiar with binary operations can follow the analysis.
    Learn the WebSocket protocol - the implementation principle from the top to the bottom
    If you are not familiar with the binary protocol, just use the algorithm provided online. Here is a PHP version for reference:
    WEBsocket Chat Room

    reply
    0
  • Cancelreply