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