pxt-common-packages 9.3.9 → 9.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ namespace azureiot {
17
17
  let _messageBusId: number;
18
18
  let _receiveHandler: (msg: Json, sysProps: SMap<string>) => void;
19
19
  let _methodHandlers: SMap<(msg: Json) => Json>;
20
+ let twinRespHandlers: SMap<(status: number, body: any) => void>
20
21
 
21
22
  function log(msg: string) {
22
23
  console.add(logPriority, "azureiot: " + msg);
@@ -156,7 +157,6 @@ namespace azureiot {
156
157
  }
157
158
  catch {
158
159
  // just ignore errors disconnecting
159
- _mqttClient = undefined
160
160
  }
161
161
  }
162
162
  }
@@ -320,16 +320,16 @@ namespace azureiot {
320
320
  c.publish('$iothub/methods/res/' + status + "/?$rid=" + props["$rid"], JSON.stringify(resp))
321
321
  }
322
322
 
323
- let twinRespHandlers: SMap<(status: number, body: any) => void>
324
-
325
323
  // $iothub/twin/res/{status}/?$rid={request id}
326
324
  function twinResponse(msg: mqtt.IMessage) {
327
325
  const args = parseTopicArgs(msg.topic)
328
326
  const h = twinRespHandlers[args["$rid"]]
329
327
  const status = parseInt(msg.topic.slice(17))
330
328
  // log(`twin resp: ${status} ${msg.content.toHex()} ${msg.content.toString()}`)
331
- if (h)
329
+ if (h) {
330
+ delete twinRespHandlers[args["$rid"]]
332
331
  h(status, JSON.parse(msg.content.toString() || "{}"))
332
+ }
333
333
  }
334
334
 
335
335
  export class ValueAwaiter {