rolancia-network

1.0.20 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i rolancia-network

Weekly Downloads

0

Version

1.0.20

License

ISC

Unpacked Size

9.74 kB

Total Files

5

Last publish

Collaborators

  • rolancia