Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@steelbreeze/broker

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@steelbreeze/broker - npm Package Compare versions

Comparing version 1.0.0-beta.5 to 1.0.0-beta.6

11

examples/testClient.js

@@ -15,6 +15,11 @@ const broker = require('../lib/index'); // replace with @steelbreeze/broker

// publish a message on the devices topic of the /events broker every second
setInterval( () => {
var timer = setInterval( () => {
client.publish('devices', `Hello at ${new Date()}`);
client.publish('device/1/2/3', `Hello at ${new Date()}`);
}, 1000);
client.publish('device/1/2/3', `Hello at ${new Date()}`, cancelTimer);
}, 1000);
function cancelTimer() {
console.log("Unable to connect");
}

@@ -11,5 +11,5 @@ /** Specifies the location of a message broker server. */

export declare function client(config: HTTPConfig): {
publish: (topicName: string, data: string) => void;
publish: (topicName: string, data: string, onError: ((err: Error) => void) | undefined) => void;
subscribe: (topicName: string, callback: (data: string) => void) => void;
};
export {};

@@ -18,4 +18,5 @@ "use strict";

*/
function publish(topicName, data) {
function publish(topicName, data, onError) {
var post = http.request({ hostname: config.host, port: config.port, path: config.path + "/" + topicName, method: 'POST', headers: { 'Content-Type': 'text/plain', 'Content-Length': Buffer.byteLength(data) } });
post.on('error', onError || (function () { }));
post.write(data);

@@ -22,0 +23,0 @@ post.end();

{
"name": "@steelbreeze/broker",
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.6",
"description": "Lightweight publish and subscribe using Server-Sent Events for node and express",

@@ -33,5 +33,6 @@ "main": "lib/index.js",

"devDependencies": {
"@types/node": "^10.5.1",
"@types/express": "^4.16.0",
"express": "^4.16.3"
}
}
}

@@ -22,5 +22,6 @@ import * as http from 'http';

*/
function publish(topicName: string, data: string): void {
function publish(topicName: string, data: string, onError: ((err: Error) => void) | undefined): void {
var post = http.request({ hostname: config.host, port: config.port, path: `${config.path}/${topicName}`, method: 'POST', headers: { 'Content-Type': 'text/plain', 'Content-Length': Buffer.byteLength(data) } });
post.on('error', onError || (() => { }));
post.write(data);

@@ -27,0 +28,0 @@ post.end();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc