1.0.20 • Published 5 years ago
rolancia-network v1.0.20
Intro
Rolancia Network is a network library to support programming that use TCP of 'net' library.
This is wrotten to use for my personal project so it would have bugs. So I don't think it's good for your project, find another well-made library.
Though that, I'am writting this written for my friend.
Import
Module
npm i --save rolancia-network;
const rolanciaNetwork = require('rolancia-network');
You are using 'import', skip this step
Networker
const Networker = rolanciaNetwork.Networker;
or
import { Networker } from 'rolancia-network';
MessagePacket
const MessagePacket = rolanciaNetwork.MessagePacket;
or
import { MessagePacket } from 'rolancia-network';
Examples
Server-side
const server = net.createServer();
server.on('connection', socket => {
const networker = new Networker(socket, messagePacket => {
const protocol = messagePacket.getProtocol();
const str = messagePacket.readString();
const uint = messagePacket.readUInt16();
});
networker.init();
});
Client-side
const socket = net.connect({ port: 50505, gost: 'localhost' });
socket.on('connect', () => {
const networker = new Networker(socket, data => {
console.log('received:', data.toString());
});
networker.init();
setInterval(() => {
const strBytes = Buffer.from('ABCDE', 'utf8');
const mp = new MessagePacket();
mp.setProtocol = '0x01';
mp.appendString('ABCDE');
mp.appendUInt16(30000);
networker.send(mp);
}, 10);
});
Boring...
I'm stopping writting this... I strived to... but Markdown Languge is shit... please just do as you can
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago