mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Update stomp docs, fix json parse over-optimism.
This commit is contained in:
parent
88ae31a6b8
commit
31318b03d7
@ -31,6 +31,14 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="stomp in">
|
<script type="text/x-red" data-help-name="stomp in">
|
||||||
<p>Connects to a server using the Stomp protocol to receive messages.</p>
|
<p>Connects to a server using the Stomp protocol to receive messages.</p>
|
||||||
|
<p>If the message received is JSON <b>msg.payload</b> will be parsed into an
|
||||||
|
object. If not it will be the raw data.</p>
|
||||||
|
<p><b>msg.headers</b> contains any header information that was also delivered.</p>
|
||||||
|
<p><b>msg.topic</b> is set to the predefined subscription topic.</p>
|
||||||
|
<p><b>Note</b>: While not a requirement of the Stomp protocol, if connecting to an ActiveMQ server, the destination should
|
||||||
|
begin with <i>"/queue/"</i> or with <i>"/topic/"</i>. See
|
||||||
|
<a href="https://stomp.github.io/stomp-specification-1.0.html#frame-SEND" target="new">Stomp 1.0 spec</a>
|
||||||
|
for more details.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -72,7 +80,12 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="stomp out">
|
<script type="text/x-red" data-help-name="stomp out">
|
||||||
<p>Connects to an Stomp capable server to send messages.</p>
|
<p>Connects to an Stomp capable server to send messages.</p>
|
||||||
<p>The <b>Destination</b> field is optional. If set it overrides the <b>msg.topic</b> property of the message.</p>
|
<p>The <b>Destination</b> field is optional. If set it overrides the <b>msg.topic</b>
|
||||||
|
property of the message.</p>
|
||||||
|
<p><b>Note</b>: While not a requirement of the Stomp protocol, if connecting to an ActiveMQ server, the destination should
|
||||||
|
begin with <i>"/queue/"</i> or with <i>"/topic/"</i>. See
|
||||||
|
<a href="https://stomp.github.io/stomp-specification-1.0.html#frame-SEND" target="new">Stomp 1.0 spec</a>
|
||||||
|
for more details.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -57,7 +57,14 @@ module.exports = function(RED) {
|
|||||||
node.status({fill:"green",shape:"dot",text:"connected"});
|
node.status({fill:"green",shape:"dot",text:"connected"});
|
||||||
node.log('subscribed to: '+node.topic);
|
node.log('subscribed to: '+node.topic);
|
||||||
node.client.subscribe(node.topic, function(body, headers) {
|
node.client.subscribe(node.topic, function(body, headers) {
|
||||||
msg.payload = JSON.parse(body);
|
try {
|
||||||
|
msg.payload = JSON.parse(body);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
msg.payload = body;
|
||||||
|
}
|
||||||
|
msg.headers = headers;
|
||||||
|
msg.topic = node.topic;
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
});
|
});
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
|
@ -16,6 +16,12 @@ Usage
|
|||||||
|
|
||||||
Connects to a Stomp capable server to send and receive messages.
|
Connects to a Stomp capable server to send and receive messages.
|
||||||
|
|
||||||
The **destination** field is optional. If set it overrides the **msg.topic** property of the message.
|
The **destination** field is optional. If set it overrides the **msg.topic**
|
||||||
|
property of the message.
|
||||||
|
|
||||||
|
As noted [here](https://github.com/easternbloc/node-stomp-client#queue-names),
|
||||||
|
while not a requirement of the Stomp protocol,
|
||||||
|
if talking to an **ActiveMQ** server the *destination* should begin with
|
||||||
|
**"/queue/"** or with **"/topic/"**.
|
||||||
|
|
||||||
This node only uses the simple security version of the stomp-client.
|
This node only uses the simple security version of the stomp-client.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-stomp",
|
"name" : "node-red-node-stomp",
|
||||||
"version" : "0.0.2",
|
"version" : "0.0.3",
|
||||||
"description" : "A Node-RED node to publish and subscribe to/from a Stomp server",
|
"description" : "A Node-RED node to publish and subscribe to/from a Stomp server",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"stomp-client" : "0.5.0"
|
"stomp-client" : "0.6.2"
|
||||||
},
|
},
|
||||||
"repository" : {
|
"repository" : {
|
||||||
"type":"git",
|
"type":"git",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user