Skip to content
Snippets Groups Projects
Commit c3efc90c authored by Marin Karamihalev's avatar Marin Karamihalev
Browse files

hopefully resolved msgId issue for notufyResp

parent 65046fc9
Branches
Tags
No related merge requests found
Pipeline #93337 passed
{ {
"name": "usp-js", "name": "usp-js",
"version": "0.3.9", "version": "0.3.10",
"description": "Helper library for easy usp communication using mqtt over tcp or ws.", "description": "Helper library for easy usp communication using mqtt over tcp or ws.",
"main": "node/index.js", "main": "node/index.js",
"browser": "web/index.js", "browser": "web/index.js",
......
...@@ -3,10 +3,10 @@ import { uniq } from "../util"; ...@@ -3,10 +3,10 @@ import { uniq } from "../util";
const decode: DecodeFn = (msg) => [msg]; const decode: DecodeFn = (msg) => [msg];
const encode: EncodeFn = ({ subscriptionId }) => ({ const encode: EncodeFn = ({ subscriptionId, msgId }) => ({
lookup: "Msg", lookup: "Msg",
header: { header: {
msgId: subscriptionId || uniq("NOTIFY_RESP@"), msgId: msgId || uniq("NOTIFY_RESP@"),
msgType: "NOTIFY_RESP", msgType: "NOTIFY_RESP",
lookup: "Header", lookup: "Header",
}, },
......
import { CallbackOptions, MakeFn, SubscribeRecipe } from "../../types"; import { CallbackOptions, MakeFn, SubscribeRecipe } from "../../types";
import { uniq } from "../util"; import { search, uniq } from "../util";
const subscriptionPath = "Device.LocalAgent.Subscription."; const subscriptionPath = "Device.LocalAgent.Subscription.";
...@@ -25,9 +25,10 @@ const make: MakeFn = ...@@ -25,9 +25,10 @@ const make: MakeFn =
// from https://usp.technology/specification/07-index-messages.html#sec:responses-and-retry // from https://usp.technology/specification/07-index-messages.html#sec:responses-and-retry
const respond = () => call("NOTIFY_RESP", { subscriptionId: id }); const respond = (msgId) =>
call("NOTIFY_RESP", { subscriptionId: id, msgId });
const clear = on(id, (msg, fullMsg, opts) => { const clear = on(id, (msg, fullMsg, opts) => {
opts?.sendResp && respond(); opts?.sendResp && respond(search(fullMsg, "msgId"));
callback(msg, fullMsg); callback(msg, fullMsg);
}); });
return () => { return () => {
......
...@@ -256,8 +256,8 @@ const buildConnect: BuildConnectionFn = ...@@ -256,8 +256,8 @@ const buildConnect: BuildConnectionFn =
supportedProto: (proto) => call("GET_SUPPORTED_PROTO", { proto }), supportedProto: (proto) => call("GET_SUPPORTED_PROTO", { proto }),
_operate: (path, id, resp, input, commandKey) => _operate: (path, id, resp, input, commandKey) =>
call("OPERATE", { path, input, id, resp, commandKey }), call("OPERATE", { path, input, id, resp, commandKey }),
_notifyResp: (subscriptionId) => _notifyResp: (subscriptionId, msgId) =>
call("NOTIFY_RESP", { subscriptionId }), call("NOTIFY_RESP", { subscriptionId, msgId }),
on, on,
...makeRecipes(call, on), ...makeRecipes(call, on),
disconnect: () => client.end(), disconnect: () => client.end(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment