0.13.3 • Published 2 years ago

pie-client v0.13.3

Weekly downloads
47
License
MIT
Repository
-
Last release
2 years ago

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:

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),
});
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));
}
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));
}
// 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

0.9.3

2 years ago

0.11.0

2 years ago

0.12.0

2 years ago

0.11.1

2 years ago

0.13.0

2 years ago

0.12.1

2 years ago

0.13.1

2 years ago

0.13.2

2 years ago

0.13.3

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.7.0

2 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.6.0

3 years ago

0.3.2

3 years ago

0.3.3

3 years ago

0.3.1

3 years ago

0.2.1

3 years ago

0.2.0

4 years ago

0.1.0

4 years ago