Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
flowagent
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node-red
flowagent
Commits
63b2f13d
Commit
63b2f13d
authored
Nov 10, 2019
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
share device subscription between shadow of the same devieid
parent
00553dd9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
coordinator.js
+17
-5
No files found.
coordinator.js
View file @
63b2f13d
...
...
@@ -16,20 +16,32 @@ const Coordinator = function(param={}) {
client
.
forward
(
topic
,
payload
,
options
,
topic
,
0
);
});
that
.
remoteclient
.
subscribe
(
`->tap/shadow/
${
deviceid
}
:
${
client
.
token
}
`
);
that
.
remoteclient
.
subscribe
(
`->tap/device/
${
deviceid
}
:
${
client
.
token
}
`
);
if
(
!
that
.
localserver
.
sublist
[
deviceid
])
{
that
.
remoteclient
.
subscribe
(
`->tap/shadow/
${
deviceid
}
:
${
client
.
token
}
`
);
that
.
remoteclient
.
subscribe
(
`->tap/device/
${
deviceid
}
:
${
client
.
token
}
`
);
that
.
localserver
.
sublist
[
deviceid
]
=
1
;
}
else
{
that
.
localserver
.
sublist
[
deviceid
]
++
;
}
});
this
.
localserver
.
on
(
'clientDisconnected'
,
function
(
client
){
console
.
log
(
'client disconnected'
,
client
.
id
);
let
deviceid
=
client
.
id
.
split
(
':'
)[
0
];
that
.
remoteclient
.
unsubscribe
(
`->tap/shadow/
${
deviceid
}
:
${
client
.
token
}
`
);
that
.
remoteclient
.
unsubscribe
(
`->tap/device/
${
deviceid
}
:
${
client
.
token
}
`
);
if
(
that
.
localserver
.
sublist
[
deviceid
]
==
1
)
{
that
.
remoteclient
.
unsubscribe
(
`->tap/shadow/
${
deviceid
}
:
${
client
.
token
}
`
);
that
.
remoteclient
.
unsubscribe
(
`->tap/device/
${
deviceid
}
:
${
client
.
token
}
`
);
that
.
localserver
.
sublist
[
deviceid
]
=
0
;
}
else
{
that
.
localserver
.
sublist
[
deviceid
]
--
;
}
});
this
.
remoteclient
.
on
(
'message'
,
function
(
topic
,
payload
){
//console.log(that.localserver.sublist);
let
jsonpayload
=
{};
try
{
jsonpayload
=
JSON
.
parse
(
payload
.
toString
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment