Lightweight real-time messaging library for JavaScript applications.
- WebSocket-based real-time communication
- Channel-based architecture
- Event-driven messaging
- Support for private channels
- Presence channels for user status tracking
- Automatic reconnection
- Zero dependencies
- Tiny footprint (~10KB gzipped)
npm install arusdata --save
<script src="https://cdn.jsdelivr.net/npm/arusdata@0.1.0/dist/arusdata.min.js"></script>
javascriptCopy// Initialize the client
const arusdata = new ArusdataClient({
endpoint: 'ws://localhost:8080/arusdata'
});
// Subscribe to a channel
const channel = arusdata.subscribe('chat-room');
// Listen for events
channel.bind('message', (data) => {
console.log(`Received message from ${data.sender}: ${data.text}`);
displayMessage(data);
});
// Send a message
channel.trigger('message', {
sender: 'John',
text: 'Hello, ArusdataJS!',
timestamp: new Date().toISOString()
});
// Connection and disconnection events
arusdata.onConnection((socketId) => {
console.log('Connected with socket ID:', socketId);
});
arusdata.onDisconnection(() => {
console.log('Disconnected from server');
});
// Initialize the client
const arusdata = new ArusdataClient({
endpoint: 'ws://your-server.com/arusdata'
});
// Subscribe to a channel
const channel = arusdata.subscribe('chat-room');
// Listen for events
channel.bind('message', (data) => {
console.log(`Received message: ${data.text}`);
});
// Send a message
channel.trigger('message', {
sender: 'John',
text: 'Hello, world!',
timestamp: new Date().toISOString()
});
// Connection events
arusdata.onConnection((socketId) => {
console.log('Connected with socket ID:', socketId);
});
arusdata.onDisconnection(() => {
console.log('Disconnected from server');
});
- WebSocket-based real-time communication
- Channel-based architecture
- Event-driven messaging
- Support for private channels
- Presence channels for user status tracking
- Automatic reconnection
- Zero dependencies
- Tiny footprint (~10KB gzipped)
ArusdataClient
javascriptCopy// Constructor
const arusdata = new ArusdataClient(options);
// Methods
arusdata.connect();
arusdata.disconnect();
arusdata.subscribe(channelName);
arusdata.unsubscribe(channelName);
arusdata.publish(channelName, eventName, data);
arusdata.onConnection(callback);
arusdata.onDisconnection(callback);
arusdata.getSocketId();
arusdata.isConnected();
Channel
javascriptCopy// Methods
channel.bind(eventName, callback);
channel.unbind(eventName, callback);
channel.trigger(eventName, data);
channel.onSubscription(callback);
For full documentation and examples, visit https://arusdatajs.com. License MIT