# bsock

> Websocket bike-shed

Latest version **0.1.11** (published 2023-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install bsock
pnpm add bsock
yarn add bsock
bun add bsock
```

## Health

**Score 5/100 (F)** — status: abandoned.

Warnings: low downloads; no types; no esm support; has vulnerabilities; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.11 |
| Published | 2023-10-31 |
| First published | 2017-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 1 |
| Unpacked size | 147.8 KB |
| Known vulnerabilities | 1 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Christopher Jeffrey |
| Maintainers | chjj, nodweber, pinheadmz |
| Keywords | tcp, http, socket.io, websockets |

## Links

- npm: https://www.npmjs.com/package/bsock
- Repository: https://github.com/bcoin-org/bsock
- Issues: https://github.com/bcoin-org/bsock/issues
- npm.io page: https://npm.io/package/bsock

## Dependencies (1)

- [bsert](https://npm.io/package/bsert.md) ~0.0.12

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.11 (latest) — 2023-10-31
- 0.1.10 — 2023-08-31
- 0.1.9 — 2019-05-03
- 0.1.8 — 2019-03-21
- 0.1.7 — 2019-03-11
- 0.1.6 — 2019-03-11
- 0.1.5 — 2019-01-22
- 0.1.4 — 2018-11-29
- 0.1.3 — 2018-09-29
- 0.1.2 — 2018-08-01
- 0.1.1 — 2018-07-19
- 0.1.0 — 2018-06-08
- 0.0.2 — 2018-03-12
- 0.0.1 — 2017-12-29
- 0.0.0 — 2017-10-18

## README

# bsock

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

## Usage

``` js
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.

---
_Source: https://npm.io/package/bsock · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
