Pawl
Pawl copied to clipboard
feature: support permessage connection in websocket
Hi there,
Thanks for this great library. Recently, I’ve been trying to connect to the server with permessage-deflate
. While the connection was established, the message wasn’t compressed, which led to a frame error. I tried encoding the message myself, but it didn’t work because the frame wasn’t correct. I noticed there is a deflateFrame
method in MessageBuffer
, and I believe it can support permessage-deflate
in WebSocket
.
In my opinion, the permessage-deflate
can be added when initializing the stream (https://github.com/ratchetphp/Pawl/blob/master/src/WebSocket.php#L69).
Let me know if you have any suggestions.
$permessageDeflateOptions = PermessageDeflateOptions::fromRequestOrResponse($request);
$sender = null;
$permessageDeflateOption = null;
if (count($permessageDeflateOptions) > 1) {
$sender = [$stream, 'write'];
$permessageDeflateOption = $permessageDeflateOptions[0];
}
$streamer = new MessageBuffer(
......
null,
null
$sender,
$permessageDeflateOption
);