0.3.10 • Published 3 months ago

tyo-mq v0.3.10

Weekly downloads
4
License
MIT
Repository
github
Last release
3 months ago

tyo-mq

NPM module

TYO-MQ is a distributed messaging (pub/sub) service with socket.io.

NPM

At the moment the message queuing is not implemented yet, which means all messages are sent instantly without confirmation of message delivery or recieving. So message subcriber(s) will need to be online in order to recieve the message.

Installation

npm install tyo-mq

Creating a messaging server

var MessageServer = require("tyo-mq").Server;

var mq = new MessageServer();
mq.start();

Creating a message producer

var Factory = require('tyo-mq').Factory,
    producer;

var mq = new Factory();  

mq.createProducer('testevent')
.then(function (p) {
    producer = p;

    // produce a default event with data {data: 'test'}
    producer.produce('test text from default event');

    // produce a different kind of event
    producer.produce('event2', {data: 'test text from event2'})
});

Creating a message subscriber

var Factory = require('tyo-mq').Factory,
    consumer;

var mq = new Factory();    

mq.createConsumer()
.then(function (c) {
    consumer = c;
    consumer.on('connect', function ()  {
        console.log('consumer\'s own connect listenr');
    });

    // subscribe 'event2'
    consumer.subscribe('event2', (data) => {
        console.log(data);
    });

    // subscribe 'testevent'
    consumer.subscribe('testevent', (data) => {
        console.log(data);
    });
});

Demo

Start the TYO-MQ server

# Needs to set up the library (module) path
export NODE_PATH=`npm config get prefix`/lib/node_modules/
node -e 'require("tyo-mq/server")'

Test Script

export NODE_PATH=`npm config get prefix`/lib/node_modules/
node -e 'require("tyo-mq/test")'

Browserify

This package supports being browserified. In order to browserify, please install two more extra packages:

npm install utf-8-validate bufferutil

Afterward,

browserify web/web.js -o web/client/tyo-mq-client.js

TODO list

  • implement the message queuing
  • message queuing if intended subscriber is down, resend message when it is up
  • message delivery for one or some intended subscribers only

Maintainer

Eric Tang @ TYO LAB

0.3.10

3 months ago

0.3.8

4 months ago

0.3.6

6 months ago

0.3.5

8 months ago

0.3.2

10 months ago

0.3.4

8 months ago

0.3.3

8 months ago

0.3.0

2 years ago

0.3.1

1 year ago

0.2.18

2 years ago

0.2.16

2 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.11

4 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago