1.0.34 • Published 8 years ago

soprano v1.0.34

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

soprano

Abstract Multi-protocol Socket Library for NodeJs

Install

npm i soprano --save

Protocols

  • EchoProtocol (Built-in Echo protocol)
  • Soprano.RPCProtocol: github / npm
    • Simple RPC (Remote Procedure Call) protocol with some cool features
  • Soprano.PubSubProtocol: github / npm
    • Publish / Subscription protocol with some cool features

Examples

Basic Usage

server.js

const Soprano = require('./');

(async function () {
    try{

        // create Soprano instance
        let soprano = new Soprano({port: 3000, host: '0.0.0.0'});

        // create Protocol instance
        let echoProtocol = soprano.createProtocol(Soprano.EchoProtocol);

        // Attach some optional middleware (this is protocol specific)
        echoProtocol.use(async function (echoData, req) {
            // modify data by adding "ECHO: " prefix
            return Buffer.concat([Buffer.from("ECHO: "), echoData]);
        });


        // Bind protocol to soprano instance
        await soprano.bind(echoProtocol);

        // Create SopranoServer and listen on specified port
        let server = await soprano.listen();

        console.log("listening on %s:%s", server.host, server.port);

    } catch (err){
        console.log(err);
    }
})();

client.js

const Soprano = require('./');

(async function () {
    try{
        // create Soprano instance
        let soprano = new Soprano();

        // create EchoProtocol instance
        let echoProtocol = soprano.createProtocol(Soprano.EchoProtocol);

        // echo something and grab the server result
        let result = await echoProtocol.echo('Hello World');

        console.log(result);
    } catch (err){
        console.log(err);
    }
})();
1.0.34

8 years ago

1.0.33

8 years ago

1.0.32

8 years ago

1.0.31

9 years ago

1.0.30

9 years ago

1.0.29

9 years ago

1.0.28

9 years ago

1.0.27

9 years ago

1.0.26

9 years ago

1.0.25

9 years ago

1.0.24

9 years ago

1.0.23

9 years ago

1.0.22

9 years ago

1.0.21

9 years ago

1.0.20

9 years ago

1.0.19

9 years ago

1.0.18

9 years ago

1.0.17

9 years ago

1.0.16

9 years ago

1.0.15

9 years ago

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago