0.0.2 • Published 7 months ago
@roostly/js v0.0.2
Roostly JavaScript SDK
A lightweight JavaScript SDK for Roostly, a Pusher-compatible WebSocket service.
Installation
npm install @roostly/jsUsage
import { Roostly } from '@roostly/js';
// Initialize the client
const client = new Roostly({
key: 'your_app_key',
host: 'your-server-host.com',
secure: true,
enableLogging: true
});
// Subscribe to a channel
const channel = client.subscribe('my-channel');
// Bind to an event on the channel
client.bind('my-channel', 'new-message', (data) => {
console.log('New message received:', data);
});
// Listen for connection events
client.on('connection_established', (event) => {
console.log('Connected with socket ID:', event.data.socketId);
});Features
- WebSocket connection management
- Channel subscriptions
- Event binding
- Automatic reconnection
- Lightweight (only 45KB)
License
MIT