You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

bsock

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bsock

Websocket bike-shed


Version published
Weekly downloads
738
decreased by-30.18%
Maintainers
1
Install size
164 kB
Created
Weekly downloads
 

Readme

Source

bsock

A minimal websocket-only implementation of the socket.io protocol, complete with ES6/ES7 features.

Usage

const http = require('http');
const bsock = require('bsock');
const io = bsock.createServer();
const server = http.createServer();

io.attach(server);

io.on('socket', (socket) => {
  // Bind = listen for event
  socket.bind('bar', (data) => {
    console.log('Received bar: %s.', data.toString('ascii'));
  });
  // Hook = listen for call (event + ack)
  socket.hook('foo', async () => {
    return Buffer.from('bar');
  });
});

server.listen(8000);

const socket = bsock.connect(8000);

socket.on('connect', async () => {
  console.log('Calling foo...');
  // Call = emit event and wait for ack
  const data = await socket.call('foo');
  console.log('Response for foo: %s.', data.toString('ascii'));
  console.log('Sending bar...');
  // Fire = emit event
  socket.fire('bar', Buffer.from('baz'));
});

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. </legalese>

License

  • Copyright (c) 2017, Christopher Jeffrey (MIT License).

See LICENSE for more info.

Keywords

FAQs

Package last updated on 03 May 2019

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc