Configuration.decodeWebSocket()
Description
Appends a decodeWebSocket filter to the current pipeline layout.
A decodeWebSocket filter decodes WebSocket messages from a raw byte stream.
- INPUT - Data stream to decode WebSocket messages from.
- OUTPUT - WebSocket Messages decoded from the input Data stream.
After decoding, the output Message has:
- head
- opcode - Interpretation of the payload
- masked - Whether the payload is masked
- body - Binary data in the body
The opcode can be:
- 1 = text data
- 2 = binary data
- 8 = connection close
- 9 = ping
- 10 = pong
Syntax
pipy().pipeline().decodeWebSocket()
Parameters
decodeWebSocket()
Return Value
The same Configuration object.
Example
pipy().listen(8080).demuxHTTP().to($=>$.acceptHTTPTunnel(msg => (((hash = new crypto.Hash('sha1'),) => (hash.update(msg.head.headers['sec-websocket-key'] +'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'),new Message({status: 101,headers: {'upgrade': 'websocket','connection': 'upgrade','sec-websocket-accept': hash.digest('base64'),}})))())).to($=>$.decodeWebSocket().replaceMessage(() => new Message({ opcode: 1 }, 'yay!')).encodeWebSocket()))