lightweight-socket
v1.0.0
Published
lightweight socket
Downloads
9
Maintainers
Readme
Lightweight Socket
Lightweight Socket is a minimal, lightweight, and efficient real-time communication library for Node.js and the browser. It is inspired by Socket.IO but aims to provide a simpler and more streamlined API.
Features
- Real-time bi-directional communication between server and client
- Lightweight and efficient
- Supports both Node.js and browser environments
- Simple and easy-to-use API
Installation
You can install Lightweight Socket via npm:
npm install lightweight-socket
Usage
Server (Node.js)
import { Server } from 'lightweight-socket'
const server = new Server({ port: 3000 });
server.on('connection', (client) => {
console.log('A client connected');
client.on('message', (data) => {
console.log('Received message from client:', data);
});
});
Client (Browser)
import { BrowserClient } from 'lightweight-socket';
const client = new BrowserClient('ws://localhost:3000');
client.on('connect', () => {
console.log('Connected to server');
client.emit('message', 'Hello, server!');
});
Building
To build the server and browser versions of the library, run:
npm run build
Contributing
Contributions are welcome! Please feel free to submit a pull request.
License
Lightweight Socket is open source software licensed as MIT.
Disclaimer
This library is inspired by Socket.IO but is not affiliated with or endorsed by the Socket.IO team. It aims to provide a lightweight alternative for real-time communication in Node.js and browser environments.