Skip to content

Mr. Pepe is a protocol to work with remote object over udp

License

Notifications You must be signed in to change notification settings

chiro-hiro/mrpepe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mr. Pepe

Mr. Pepe provide protocol to work with remote object over UDP.

How to create Mr. Pepe server?

const mrPepe = require('mrpepe');
const crypto = require('crypto');

var localObject = {
    sha256: (data) => {
        return crypto.createHash('sha256').update(data).digest().toString('hex');
    },
    sum: (a, b) => {
        return a+b;
    }
};

var server = new mrPepe.server({
    address: '127.0.0.1',
    port: 3301,
    protocol: 'udp4',
    child: 4
}, localObject);

server.start();

This source code create a service binding to port 3301 with 4 child process. All method of localObject will be provide as res API. Of couse Mr. Pepe support UDP/IPv4 and UDP/IPv6.

How to create Mr. Pepe client?

const mrPepe = require('mrpepe');

var client = new mrPepe.client({
    address: '127.0.0.1',
    port: 3301,
    protocol: 'udp4',
});

client.call('sha256', [new Buffer('Chiro may cry!.')], (error, data, rinfo) => {
    console.log(`Error: ${error}\nData: ${data}\nFrom: ${rinfo.address}:${rinfo.port}.`);
});

client.call('sum', [4,5], (error, data, rinfo) => {
    console.log(`Error: ${error}\nData: ${data}\nFrom: ${rinfo.address}:${rinfo.port}.`);
});

This source code create UDP datagram connect to server following configuration. It'll trigger localObject over UPD.

Future works

  • Support callback function
  • Parsing parameters in Buffer type
  • Encrypt transfer data

License

This software distributed under MIT License

About

Mr. Pepe is a protocol to work with remote object over udp

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published