New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

tcppubsub

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcppubsub - npm Package Compare versions

Comparing version
1.0.0
to
1.0.1
public/tcppubsub.png

Sorry, the diff of this file is not supported yet

+25
-17
var tcppubsub = require('../lib/main')
var port = 2223
var host = 'localhost'
//Create the member
var member = new tcppubsub.Member(port, host)
member.connect(function(){
//Subscribe the topic without callback
member.sub('app/configuration/service')
// Subscribe the topic STRING or ARRAY
member.sub('app/configuration/server', function(topic){
// Publish some data STRING, OBJECT, ARRAY
member.pub('app/configuration/server', {name: 'yamigr', b : 'Hello World'})
})
// Receive the data on the certain topic
member.on('app/configuration/server', function(data){
// Unsubscribe the topic

@@ -29,18 +31,24 @@ member.unsub('app/configuration/server')

})
/******* OR *******/
// Receive all publishes on subscribed data
member.on('message', function(topic, data){
member.unsub('app/configuration/server')
console.log(topic, data)
})
member.listen('app/static/config', function(data, res){
console.log('rcv request for static data:', data)
res({ msg: 'Hello ' + data.name})
})
let timeout = 2000 // default 5000
member.req('app/static/config', { name : 'Peter Pan'}, function(err, data, id){
if(err){
// timeout error
}else{
if(!err){
console.log('rcv response:', data.msg)
}
}, timeout)
})
})

@@ -16,3 +16,3 @@

this.eof = '\n'
this.block = block ? block : false
this.block = block ? block : true
}

@@ -19,0 +19,0 @@

{
"name": "tcppubsub",
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple node-js-tcp publish-subscribe framework. With a broker and a client called member.",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

# tcppubsub
> A simple node-js-tcp publish-subscribe-request-response framework :octopus:. With a broker and a client called member.
> A simple and lightweight submarine build with publish-subscribe-request-response-methods. With a broker called broker :octopus: and a client called member :dolphin:.
A simple and fast :leopard: exchange of data between nodejs-applications.Use the publish-subscribe-pattern to handle events or use the request-response-pattern to query or serve some data.
![tcppubsub icon](/public/tcppubsub.png?raw=true)
A simple and fast exchange of data between nodejs-apps. Use the publish-subscribe-pattern to handle events or use the request-response-pattern to query or serve some data. Otherwise, get into a submarine and look for the octopus.
* [Go to broker](#broker)

@@ -22,4 +24,6 @@ * [Go to member](#member)

A broker handles all data from the members, like sockets, topics and payload. You can use some events do handle the member-data directly at the broker-side.
A broker handles all data from the members, like sockets, topics and payload. You can use some events to handle the member-data directly at the broker-side.
### Example
```js

@@ -30,5 +34,5 @@ var tcppubsub = require('tcppubsub')

var host = 'localhost'
var blockPublisher = false // block payload sending to publisher, if he has subscribed the topic too
var block = true // block payload sending to publisher, if he has subscribed the topic too. Default: true
var broker = new tcppubsub.Broker(port, host, blockPublisher)
var broker = new tcppubsub.Broker(port, host, block)
broker.listen()

@@ -51,7 +55,7 @@

## Member :leopard:
## Member :dolphin:
* Publish-subscribe data.
* Listen on requests.
* Request some data from listeners.
* Query some data from listeners.
* Topic without wildcard 'app/configuration/server' .

@@ -58,0 +62,0 @@ * Topic with wildcard 'app/configuration/#' or 'app/#/configuration',....