https://github.com/javanile/centralio
Client/Server library for UDP
https://github.com/javanile/centralio
client-server node-module nodejs state-machine udp udp-client udp-server
Last synced: 12 days ago
JSON representation
Client/Server library for UDP
- Host: GitHub
- URL: https://github.com/javanile/centralio
- Owner: javanile
- License: mit
- Created: 2017-12-08T22:57:46.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2022-02-05T22:03:28.000Z (over 3 years ago)
- Last Synced: 2025-04-12T21:52:22.698Z (3 months ago)
- Topics: client-server, node-module, nodejs, state-machine, udp, udp-client, udp-server
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Centralio
Centralio is a library for creating applications with many clients and a central server based on the UDP protocol.[](https://travis-ci.org/javanile-bot/centralio)
[](https://codeclimate.com/github/javanile-bot/centralio/maintainability)
[](https://codeclimate.com/github/javanile-bot/centralio/test_coverage)## Get Starded
If you want use Centralio simply add dependency into your project
```bash
$ npm install centralio
```### Your first server
```javascript
// file: server.js
// exec: node server
const server = require('centralio').server();// Start your server
server.start('127.0.0.1', '44044');// Handle received messages from client
server.rx(function(client, msg) {
console.log('Message from client:', client.id, msg);
// Respond to client
client.tx('Thanks from your message.');
});
```### Your first client
```javascript
// file: client.js
// exec: node client
const client = require('centralio').client();// Start your client
client.start('127.0.0.1', '44044');// Handle received message from server
client.rx(function(msg) {
console.log('Message from server:', msg);
});// Send message to server
client.tx('Hi my server!');
```## Manage client state
