Skip to content

AhmadMuzayyin/arusdata-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArusdataJS

Lightweight real-time messaging library for JavaScript applications.

Features

  • 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)

Installation

NPM

npm install arusdata --save

CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/arusdata.min.js"></script>

Quick Start

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');
});

Usage

// 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');
});

Features

  • 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)

API Reference

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);

Documentation

For full documentation and examples, visit https://arusdatajs.com. License MIT

About

No description, website, or topics provided.

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors