Git Product home page Git Product logo

permessage-deflate-ruby's Introduction

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:

  • :level: sets the compression level, can be an integer from 0 to 9, or one of the constants Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, or Zlib::DEFAULT_COMPRESSION
  • :mem_level: sets how much memory the compressor allocates, can be an integer from 1 to 9, or one of the constants Zlib::MAX_MEM_LEVEL, or Zlib::DEF_MEM_LEVEL
  • :strategy: can be one of the constants Zlib::FILTERED, Zlib::HUFFMAN_ONLY, Zlib::RLE, Zlib::FIXED, or Zlib::DEFAULT_STRATEGY

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:

  • :no_context_takeover: if true, stops the session reusing a deflate context between messages
  • :request_no_context_takeover: if true, makes the session tell the other peer not to reuse a deflate context between messages
  • :max_window_bits: an integer from 8 to 15 inclusive that sets the maximum size of the session's sliding window; a lower window size will be used if requested by the peer
  • :request_max_window_bits: an integer from 8 to 15 inclusive to ask the other peer to use to set its maximum sliding window size, if supported

permessage-deflate-ruby's People

Contributors

jcoglan avatar benv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.