Pika-Pichu is a simple wrapper around the W3CWebSocket API which allows you to easily connect to the pikachu WebSocket server.
Via npm:
npm install pika-pichu
Via Yarn:
yarn add pika-pichu
import { Pichu } from 'pika-pichu';
const url = 'ws://localhost:8080';
const token = 'my-token';
const pikaPichu = new PikaPichu(url, token);
// client connects to the server automatically when it is constructed
pikaPichu.sendJSON({
type: 'message',
data: 'Hello world!'
});
pikaPichu.GetJSONMessageon((data) => {
console.log(data);
});