Home

Awesome

permessage-deflate

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

Installation

$ npm install permessage-deflate

Usage

Add the plugin to your extensions:

var Extensions = require('websocket-extensions'),
    deflate    = require('permessage-deflate');

var exts = new Extensions();
exts.add(deflate);

The extension can be configured, for example:

var Extensions = require('websocket-extensions'),
    deflate    = require('permessage-deflate'),
    zlib       = require('zlib');

deflate = deflate.configure({
  level: zlib.Z_BEST_COMPRESSION,
  maxWindowBits: 13
});

var exts = new Extensions();
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: