Home

Awesome

permessage_deflate

Implements the permessage-deflate WebSocket protocol extension as a plugin for websocket-extensions.

Installation

$ gem install permessage_deflate

Usage

Add the plugin to your extensions:

require 'websocket/extensions'
require 'permessage_deflate'

exts = WebSocket::Extensions.new
exts.add(PermessageDeflate)

The extension can be configured, for example:

require 'websocket/extensions'
require 'permessage_deflate'

deflate = PermessageDeflate.configure(
  :level => Zlib::BEST_COMPRESSION,
  :max_window_bits => 13
)

exts = WebSocket::Extensions.new
exts.add(deflate)

The set of available options can be split into two sets: those that control the session's compressor for outgoing messages and do not need to be communicated to the peer, and those that are negotiated as part of the protocol. The settings only affecting the compressor are described fully in the Zlib documentation:

The other options relate to settings that are negotiated via the protocol and can be used to set the local session's behaviour and control that of the peer: