New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mqlight-dev

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqlight-dev - npm Package Compare versions

Comparing version 0.1.2014041000 to 0.1.2014041401

96

mqlight.js

@@ -342,2 +342,42 @@ /* %Z% %W% %I% %E% %U% */

var messenger = client.messenger;
var check_for_messages = function() {
var messages = messenger.receive(50);
if (messages.length > 0) {
for ( var i = 0, tot = messages.length; i < tot; i++) {
var protonMsg = messages[i];
// if body is a JSON'ified object, try to parse it back to a js obj
var data;
if (protonMsg.contentType === 'application/json') {
try {
data = JSON.parse(protonMsg.body);
} catch (_) {
console.warn(_);
}
} else {
data = protonMsg.body;
}
var topic = url.parse(protonMsg.address).path.substring(1);
var delivery = {
message: {
properties: {
contentType : protonMsg.contentType,
},
topic: topic,
}
};
client.emit('message', data, delivery);
}
}
if (!messenger.stopped) {
setImmediate(check_for_messages);
}
};
process.nextTick(function() {
if (!messenger.stopped) {
check_for_messages();
}
});
return;

@@ -515,3 +555,3 @@ };

// Validate the passed parameters
if (topic === undefined) {
if (!topic) {
throw new Error('Cannot send to undefined topic');

@@ -587,8 +627,13 @@ } else if (typeof topic !== 'string') {

if (sendCallback) {
var message = {
address : decodeURIComponent(protonMsg.address),
contentType : protonMsg.contentType,
body : protonMsg.body
var topic =
url.parse(decodeURIComponent(protonMsg.address)).path.substring(1);
var delivery = {
message: {
properties: {
contentType : protonMsg.contentType,
},
topic: topic,
}
};
setImmediate(sendCallback, undefined, message);
setImmediate(sendCallback, undefined, protonMsg.body, delivery);
}

@@ -653,4 +698,4 @@ return;

// Validate the pattern parameter
if (pattern === undefined) {
throw new Error('Cannot subscribe to undefined pattern');
if (!pattern) {
throw new Error('Cannot subscribe to undefined pattern.');
} else if (typeof pattern !== 'string') {

@@ -730,37 +775,2 @@ throw new TypeError('pattern must be a string type');

if (!err) {
var check_for_messages = function() {
var messages = messenger.receive(50);
if (messages.length > 0) {
for ( var i = 0, tot = messages.length; i < tot; i++) {
var protonMsg = messages[i];
var message = {
address : protonMsg.address,
contentType : protonMsg.contentType,
body : protonMsg.body
};
// if body is a JSON'ified object, try to parse it back to a js obj
if (message.contentType === 'application/json') {
try {
var obj = JSON.parse(message.body);
message.body = obj;
} catch (_) {
console.log(_);
}
}
client.emit('message', message);
}
}
if (!messenger.stopped) {
setImmediate(check_for_messages);
}
};
process.nextTick(function() {
if (!messenger.stopped) {
check_for_messages();
}
});
}
return client;

@@ -767,0 +777,0 @@ };

{
"name": "mqlight-dev",
"version": "0.1.2014041000",
"version": "0.1.2014041401",
"description": "IBM MQ Light Client Module",

@@ -5,0 +5,0 @@ "main": "mqlight.js",

@@ -44,2 +44,4 @@ # node-mqlight (alpha)

client.connect();
var client = mqlight.createClient({

@@ -51,7 +53,10 @@ clientId: 'client-id2'

client.on('connected', function() {
var destination = client.createDestination(address);
destination.on('message', function(msg) {
console.log(msg);
client.subscribe(address);
client.on('message', function(data, delivery) {
console.log(data);
});
});
client.connect();
```

@@ -65,12 +70,17 @@

* `options`, (Object) (optional) options for the client. Properties include:
* `options`, (Object) options for the client. Properties include:
* **host**, (String, default: localhost), the remote hostname to which we
will connect.
* **port**, (Number, default: 5672), the remote tcp port to connect to.
* **clientId** (String, default: AUTO_[0-9a-f]{7}), a unique identifier for
* **service**, (String) (required), the URL for the service to connect to.
* **id** (String, default: AUTO_[0-9a-f]{7}), a unique identifier for
this client.
* **user** (String) (optional) user name for authentication
* **password** (String) (optional) password for authentication
Returns `Client` object representing the client instance.
### mqlight.Client.connect([`callback`])
Connects the MQ Light client instance to the service.
* `callback` - (Function) (optional) callback to be notified of errors &
completion
### mqlight.Client.send(`topic`, `message` [, `options` [, `callback`]])

@@ -89,5 +99,5 @@

### mqlight.Client.createDestination(`pattern` [, `options` [, `callback`]])
### mqlight.Client.subscribe(`pattern` [, `share` [,`options` [, `callback`]]])
Create a `Destination` and associates it with a `pattern`.
Create a `subscription` and associates it with a `pattern`.

@@ -99,15 +109,33 @@ The `pattern` is matched against the `address` attribute of messages sent to

* `pattern` - (String) used to match against the `address` attribute of
messages to determine if a copy of the message should be delivered to the
`Destination`.
messages to determine if a copy of the message should be received.
* `share` - (String) (optional) name for creating or joining a shared
subscription for which messages are anycast between connected subscribers. If
omitted defaults to unshared (e.g. private).
* `options` - (Object) (optional) map of additional options for the destination.
* `callback` - (Function) callback to be notified of errors & completion.
Returns a `Destination` which will emit `message` events on arrival.
Returns the `Client` object that the subscribe was called on which will emit
`message` events on arrival.
### mqlight.Client.close()
### mqlight.Client.getId()
Returns the identifier associated with the client. This will either be what
was passed in on the `Client.createClient` call or an autogenerated id.
### mqlight.Client.getService()
Returns the URL of the service to which the client is currently connected
to, or undefined if not connected.
### mqlight.Client.getState()
Returns the current state of the client, which will be one of:
'connected', 'connecting', 'disconnected' or 'disconnecting'.
### mqlight.Client.disconnect([callback])
Disconnects this Client from the messaging server and frees the system
resources that it uses. Calling this method also implicitly closes any
Destination objects that have been created using the client's
`Client.createDestination` method.
subscriptions that have been created using the client's
`Client.subscribe` method.

@@ -114,0 +142,0 @@ ## Samples

@@ -96,3 +96,3 @@ /* %Z% %W% %I% %E% %U% */

// now subscribe to topic for publications
var destination = client.subscribe(topic, function(err, address) {
client.subscribe(topic, function(err, address) {
if (err) {

@@ -109,6 +109,7 @@ console.error('Problem with subscribe request: ' + err.message);

var i = 0;
destination.on('message', function(msg) {
client.on('message', function(data, delivery) {
console.log('# received message (%d)', (++i));
console.log(msg);
console.log(data);
console.log(delivery);
});
});

@@ -88,3 +88,3 @@ /* %Z% %W% %I% %E% %U% */

var remain = parsed.argv.remain;
var data = (remain.length > 0) ? remain : [ "Hello World!" ];
var messages = (remain.length > 0) ? remain : [ "Hello World!" ];

@@ -109,4 +109,4 @@ // insert a delay between sends if requested

var sendNextMessage = function() {
var body = data[i];
client.send(topic, body, function(err, msg) {
var body = messages[i];
client.send(topic, body, function(err, data, delivery) {
if (err) {

@@ -116,8 +116,9 @@ console.error('Problem with send request: ' + err.message);

}
if (msg) {
if (data) {
console.log("# sent message:");
console.log(msg);
console.log(data);
console.log(delivery);
}
// if there are more messages pending, send the next in <delay> seconds
if (data.length > ++i) {
if (messages.length > ++i) {
if (delay > 0) {

@@ -124,0 +125,0 @@ setTimeout(sendNextMessage, delay);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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