🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

spacesocket

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spacesocket

WebSocket server not invented here

0.0.1
latest
npm
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

WebSockets From Space*

* There are no users in space, only astronauts with the latest browser. Therefore no graceful fallback is attempted.

API

Setup

var server = http.createServer(...);
server.listen(port);

require('spacesocket').attach(server, function(conn) {
    dealWithWebSocket(conn);
});

Reading

conn.on('data', function(msg) {
    doStuffWithString(msg);
});

Writing

conn.write('Hello, World');

Closure

conn.end();

Buffer control

conn.on('drain', function() {
    // socket write queue is empty,
    // send until queueing again:
    while(conn.send(data)) { }
});

// Throttle sender for 1s:
conn.pause();
setTimeout(function() { conn.resume(); }, 1000);

FAQs

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