New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

shitsocket

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shitsocket

Simulates laggy websockets for testing networked apps.

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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);

FAQs

Package last updated on 29 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc