walkor / GatewayWorker

Distributed realtime messaging framework based on workerman.
MIT License
1.01k stars 296 forks source link

how to enable WEBSOCKET_EXTENSIONS: permessage-deflate And set server_max_window_bits #95

Closed hafung closed 2 years ago

hafung commented 2 years ago

please give me some guide, because i can't find any useful in offical doc

OR how to compress data in order to save Bandwidth?

thanks!

walkor commented 2 years ago

how to enable WEBSOCKET_EXTENSIONS: permessage-deflate And set server_max_window_bits

Gatewayworker has no such configuration.

If you want to compress data. Here is the example.

start_gateway.php

...
use Workerman\Protocols\Websocket;
$gateway = new Gateway("websocket://0.0.0.0:7272");
$gateway->onConnect = function($connection) {
    $connection->websocketType = Websocket::BINARY_TYPE_ARRAYBUFFER;
};
...

Events.php

...
$data = 'hello world';
$data = gzcompress($data);
Gateway::sendToAll($data);
...
hafung commented 2 years ago

Thanks! It helps