@lovetap/websocket-client
v2.1.1
Published
The official Lovetap WebSocket API client
Downloads
7
Readme
@lovetap/websocket-client
The official Lovetap WebSocket API client. This is a low-level client that is used by the Lovetap SDKs. There are definitely easier ways to connect to Lovetap, such as the vanilla JS SDK, but you are welcome to use this library directly.
Installation
npm install @lovetap/websocket-client
Usage
Connections to the Lovetap WebSocket API are authenticated using an API key. You can find your API keys on the My Account page.
import { LovetapWebSocketClient } from "@lovetap/websocket-client";
const client = new LovetapWebSocketClient();
// For verbose logging, you can use `new LovetapWebSocketClient({logLevel: "debug"})`
await client.connect({
apiKey: "YOUR_API_KEY",
onServerMessage: (message) => console.log(message),
});
client.visit("my-page-key");
client.react("my-page-key", "👍");
client.leave("my-page-key");
setTimeout(() => {
client.disconnect();
}, 1000);
© 2023 Lovetap LLC