Allow greater control of websockets in the api without relying on libs with socket.io and ws. Looking for the basic implementation of reading and writing data and connection handshake for projects where socket.io and ws do not support the required functionalities in the project.
It is not possible to receive or send text messages longer than 65522 characters.
Frame Websocket
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len | Extended payload length |
|I|S|S|S| (4) |A| (7) | (16/64) |
|N|V|V|V| |S| | (if payload len==126/127) |
| |1|2|3| |K| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+
| |Masking-key, if MASK set to 1 |
+-------------------------------+-------------------------------+
| Masking-key (continued) | Payload Data |
+-------------------------------- - - - - - - - - - - - - - - - +
: Payload Data continued ... :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Payload Data continued ... |
+---------------------------------------------------------------+
More references
https://www.rfc-editor.org/rfc/rfc6455
-
Handeshake
-
Simple frame reading (hexadecimal -> 0x1 | typescript -> opcode 0x01) and closed frame detection (hexadecimal -> 0x8 | typescript -> opcode 0x08)
-
Interpret ping frame (hexadecimal -> 0x9 | typescript -> opcode 0x09)
-
Interpret pong frame (hexadecimal -> 0xA | typescript -> opcode 0x0A)
I'm curious what the performance is like for this? Does this actually work?