Advertisement
g1lmr

connection_source.json

Oct 5th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.58 KB | Source Code | 0 0
  1. {
  2.     "targetActorSelection": "/system/sharding/connection",
  3.     "headers": {
  4.         "aggregate": false
  5.     },
  6.     "piggybackCommand": {
  7.         "type": "connectivity.commands:createConnection",
  8.         "connection": {
  9.             "id": "mqtt-connection-source",
  10.             "connectionType": "mqtt",
  11.             "connectionStatus": "open",
  12.             "failoverEnabled": true,
  13.             "uri": "tcp://91.121.93.94:1883",
  14.             "sources": [{
  15.                 "addresses": ["my.mqtt.test/#"],
  16.                 "authorizationContext": ["nginx:ditto"],
  17.                 "qos": 0,
  18.                 "filters": []
  19.             }],
  20.             "mappingContext": {
  21.                 "mappingEngine": "JavaScript",
  22.                 "options": {
  23.                     "incomingScript": "function mapToDittoProtocolMsg(headers, textPayload, bytePayload, contentType) {const jsonString = String.fromCharCode.apply(null, new Uint8Array(bytePayload)); const jsonData = JSON.parse(jsonString); const thingId = jsonData.thingId.split(':'); const value = {measurements: {properties: {temperature: jsonData.temperature, humidity: jsonData.humidity}}}; return Ditto.buildDittoProtocolMsg(thingId[0], thingId[1], 'things', 'twin', 'commands', 'modify', '/features', headers, value);}",
  24.                     "outgoingScript": "function mapFromDittoProtocolMsg(namespace, id, group, channel, criterion, action, path, dittoHeaders, value, status, extra) {return null;}",
  25.                     "loadBytebufferJS": "false",
  26.                     "loadLongJS": "false"
  27.                 }
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement