# pie-client

> A client for connecting to, sending and receiving messages from a pie server instance

Latest version **0.13.3** (published 2022-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install pie-client
pnpm add pie-client
yarn add pie-client
bun add pie-client
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.13.3 |
| Published | 2022-03-23 |
| First published | 2020-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jordan O'Leary / Matt Sweda |
| Maintainers | jdoleary |

## Links

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

## Recent versions

- 0.13.3 (latest) — 2022-03-23
- 0.13.2 — 2022-03-23
- 0.13.1 — 2022-03-23
- 0.13.0 — 2022-03-23
- 0.12.1 — 2022-03-23
- 0.12.0 — 2022-03-23
- 0.11.1 — 2022-03-23
- 0.11.0 — 2022-03-23
- 0.10.0 — 2022-03-22
- 0.9.3 — 2022-03-21
- 0.9.2 — 2022-03-21
- 0.9.1 — 2022-03-21
- 0.9.0 — 2022-03-21
- 0.8.1 — 2022-03-19
- 0.8.0 — 2022-03-19
- … 10 more at https://npm.io/package/pie-client/versions

## README

# Pie Client

A client for connecting to, sending and receiving messages from a PieServer instance.

This package is a PieServer client that abstracts PieServer's public API behind simple publicly exported methods.

## Getting started, simplest usage:

```js
import PieClient from 'pie-client';

const pie = new PieClient({
  env: 'development',
  wsUri: 'ws://localhost:8000',
  onData: console.log,
  onError: console.error,
  onServerAssignedData: console.log,
  onClientPresenceChanged: console.log,
  onRooms: rooms => console.log('rooms', rooms),
  onConnectInfo: ({ connected }) => console.log('Connected', connected),
});
```

```js
function onConnected() {
  // To make a room, once connected
  pie
    .makeRoom({
      app: 'Some app name',
      name: 'Rock Paper Sissors Unlimited Room!',
      version: '0.1',
      private: true,
    })
    .then(() => console.log('New room made!'))
    .catch(e => console.error('Could not make new room:', e));
}
```

```js
function onConnected() {
  // To join a room, once connected
  pie
    .joinRoom({
      app: 'Some app name',
      name: 'Rock Paper Sissors Unlimited Room!',
      version: 'v0.1',
    })
    .then(() => console.log('Join succeeded!'))
    .catch(e => console.error('Join failed:', e));
}
```

```js
// To send data to everyone in the room
pie.sendData({
  any: 'data',
});
```

## Extras

Add `<div id='websocket-pie-connection-status'></div>` to the page to have PieClient automatically update it with the connection status

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