A simple and lightweight submarine build with publish-subscribe-request-response-methods. With a broker called broker 🐙 and a client called member 🐬.
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.
npm i tcppubsub
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.
var tcppubsub =var port = 2223var host = 'localhost'var block = true // block payload sending to publisher, if he has subscribed the topic too. Default: true (blocked)var broker = port host blockbrokerbroker// Publish on topics from brokerbroker//use the socket-events like:brokerbrokerbrokerbrokerbrokerbroker
- Publish-subscribe data.
- Listen on requests.
- Query some data from listeners.
- Topic without wildcard 'app/configuration/server' .
- Topic with wildcard 'app/configuration/#' or 'app/#/configuration',....
- Data can be a string or a object and is emitted as a buffer.
- When the broker restarting, it will automatically resubscribe all topics from subscription or listeners.
Call the connect-method to connect the member.
Subscribe a topic. For multiple topics give a array of topics like ['topic1', 'topic2',...].
Unsubscribe a topic. For multiple topics give a array of topics like ['topic1', 'topic2',...].
Publish some data on a topic.
Make a request on a listener topic. Set some timeout in ms for handle timeout-errors. Default-timeout: 10min.
Listen on a specific topic for requests. Handle the data and send the response with res.
Catch a message-event with namespace
message for receiving all messages or use a specific topic.
member/******* OR *******/member
var tcppubsub =var port = 2223var host = 'localhost'//Create the membervar member = port hostmember
- Benchmark tests (broker and members)
This project is licensed under the MIT License - see the LICENSE.md file for details