# websocketizer

> Websocket client/server

Latest version **1.0.11** (published 2016-12-20) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2016-12-20 |
| First published | 2016-12-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Giuseppe Menti |
| Maintainers | mentito |

## Links

- npm: https://www.npmjs.com/package/websocketizer
- npm.io page: https://npm.io/package/websocketizer

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) ^1.1.1
- [crypto](https://npm.io/package/crypto.md) 0.0.3
- [bufferutil](https://npm.io/package/bufferutil.md) ^1.3.0

## Recent versions

- 1.0.11 (latest) — 2016-12-20
- 1.0.10 — 2016-12-20
- 1.0.9 — 2016-12-19
- 1.0.8 — 2016-12-19
- 1.0.7 — 2016-12-19
- 1.0.5 — 2016-12-19
- 1.0.4 — 2016-12-19
- 1.0.3 — 2016-12-19
- 1.0.2 — 2016-12-19
- 1.0.0 — 2016-12-19

## README

# Websocketizer

> Simple websocket client with reconnecter and server using 'ws' (https://github.com/websockets/ws)

## Server use

```js
import { Server } from 'websocketizer';

// same options of 'ws'
const server = new Server({
	port: 7001,
});

server.onConnection((socket) => {
	console.log(`${socket.id} connected`);

    // send to all connections
    server.emit('receivedConnection', socket.id);

    // send to specific connection
    socket.emit('youAreConnected');
});

server.onDisconnection((socket) => {
	console.log(`${socket.id} disconnected`);

    // send to all connections
    server.emit('receivedDisconnection', socket.id);
});

// execute on receive packet 'ping'
server.on('ping', (socket) => {
	console.log(`${socket.id} pinged`);

    // respond with packet 'pong'
	socket.emit('pong');
});

server.start();
```

## Build Setup

``` bash
# install dependencies
npm install

# build for production with minification
npm run build

# start compiled version.
npm run start

# run lint in code
npm run lint
```

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