Giter Site home page Giter Site logo

shitsocket's Introduction

ShitSocket

Build Status

ShitSocket emaulates Socket.io-based websocket connections over laggy connections by adding random delays to the propogation of messages.

Message ordering is preserved; where the delay of the 1st message is greater than the 2nd, the 2nd will be held up until the first is ready to send. This will have the effect of clustering messages, which mimics the behavior of slower network connections reasonably well.

Why would you do this? ShitSocket is designed to help you write websocket code that is resilient to slower network connections, by giving you a good test case on your local development environment.

Usage

Where you would normally connect to a socket.io socket:

var io = require('socket.io');

var socket = io.connect('http://example.org');

Instead wrap the connect() call in a ShitSocket constructor:

var io = require('socket.io');
var socket = io.connect('http://example.org');
var ShitSocket = require('shitsocket');

var socket = new ShitSocket(io.connect('http://example.org'));

By default, the delays on message will be a random amount between 0 and 500ms. To change the upper limit, pass a 2nd argument to the ShitSocket constructor.

var okaySocket = new ShitSocket(io.connect('http://example.org'), 50);
var awfulSocket = new ShitSocket(io.connect('http://example.org'), 5000);

shitsocket's People

Watchers

James Cloos avatar

shitsocket's Issues

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.