libranda-client
v0.3.0
Published
A library for the client to connect to libranda-server
Maintainers
Readme
libranda-client
A robust WebSocket client library for connecting to Libranda Server with built-in reconnection and event management.
📚 View Full Documentation | 🚀 View Examples | 🖥️ View Server
Features
- Automatic reconnection handling
- Event-based communication
- Type-safe event system
- Client metadata management
- Connection state tracking
- Namespaced events
- Ready state callbacks
Installation
npm install libranda-clientQuick Start
import { LibrandaClient } from 'libranda-client';
// Create a client instance
const client = new LibrandaClient({
url: 'ws://localhost:3000',
autoReconnect: true,
reconnectInterval: 5000
});
// Register event handler
client.registerEvent(
'chat',
'message',
(data) => {
console.log('Received chat message:', data.message);
}
);
// Connect to server
client.connect();
// Send events when ready
client.ready((clientId) => {
console.log(`Connected with ID: ${clientId}`);
client.send('chat', 'message', {
message: 'Hello, server!'
});
});Documentation
For detailed API documentation, advanced usage, and best practices, see the documentation.
For working examples and sample implementations, visit our examples repository.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
