# ws-client-server

> Wrapper for native WebSocket

Latest version **1.8.0** (published 2019-04-17) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ws-client-server
pnpm add ws-client-server
yarn add ws-client-server
bun add ws-client-server
```

## 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.8.0 |
| Published | 2019-04-17 |
| First published | 2018-07-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 72.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ibabasik@yandex.ru |
| Maintainers | babasik |

## Links

- npm: https://www.npmjs.com/package/ws-client-server
- Repository: https://github.com/ibabasik/ws-client-server
- Homepage: https://github.com/ibabasik/ws-client-server#readme
- Issues: https://github.com/ibabasik/ws-client-server/issues
- npm.io page: https://npm.io/package/ws-client-server

## Dependencies (4)

- [ws](https://npm.io/package/ws.md) ^6.1.0
- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [intel](https://npm.io/package/intel.md) ^1.2.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.10

## Recent versions

- 1.8.0 (latest) — 2019-04-17
- 1.7.2 — 2019-03-08
- 1.7.1 — 2019-02-14
- 1.7.0 — 2019-02-11
- 1.6.0 — 2019-01-11
- 1.5.0 — 2019-01-11
- 1.4.2 — 2019-01-11
- 1.4.1 — 2019-01-11
- 1.4.0 — 2019-01-11
- 1.3.3 — 2018-11-23
- 1.3.2 — 2018-11-23
- 1.3.1 — 2018-11-09
- 1.3.0 — 2018-11-09
- 1.2.1 — 2018-10-02
- 1.2.0 — 2018-10-02
- … 5 more at https://npm.io/package/ws-client-server/versions

## README

UWS Server and Client Wrappers
----------------------------------------------------------------

Provides two classes:

* WsServer({ server, port })

    WsServer wraps native WebSocket.Server. It stores connected
    clients in clients array and fires 'connection' event on
    every connected client and wraps it in WsClient. 
    On client disconnect it removes it from clients array.
* WsClient()

    WsClient wraps native WebSocket and provides a way to 
    use it like socket.io (with promises)
    * Methods:
        * setInterceptor
        * say(eventName, data = {}) - send message to server 
        without waiting for response
        * ask(eventName, data = {}) -> Promise - send message 
        to server with response 
        * on(eventName, handler) - subscribe to system events
        like 'open' or 'close'
        * onSay(eventName, handler) - subscribe to custom events
        like server broadcast
        * onAsk - same as onSay for now
        * close - disconnect from server
        * connect(connectionString) - connect to server

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