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
18ebc7d4
Commit
18ebc7d4
authored
Aug 11, 2021
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add feedwatcher
parent
c02834a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
coordinator.js
+33
-2
flowemitter.js
+10
-0
No files found.
coordinator.js
View file @
18ebc7d4
module
.
exports
.
create
=
create
module
.
exports
.
create
=
create
const
DEBUG
=
fals
e
;
const
DEBUG
=
tru
e
;
const
events
=
require
(
'events'
);
const
events
=
require
(
'events'
);
const
cache
=
require
(
'./cache'
);
const
cache
=
require
(
'./cache'
);
const
RESETDELAY
=
1000
const
RESETDELAY
=
1000
const
Coordinator
=
function
(
param
=
{})
{
const
Coordinator
=
function
(
param
=
{})
{
let
that
=
this
;
let
that
=
this
;
let
resettimer
=
0
;
let
resettimer
=
0
;
...
@@ -22,6 +21,38 @@ const Coordinator = function(param={}) {
...
@@ -22,6 +21,38 @@ const Coordinator = function(param={}) {
this
.
mqttclient
=
param
.
mqttclient
;
this
.
mqttclient
=
param
.
mqttclient
;
this
.
flowemitter
=
param
.
flowemitter
||
null
;
this
.
flowemitter
=
param
.
flowemitter
||
null
;
this
.
flowemitter
.
on
(
'registerfeedwatcher'
,
function
(
client
){
let
deviceid
=
client
.
deviceid
;
let
devicetoken
=
client
.
devicetoken
;
let
outtopic1
=
`@tap/feed/updated/
${
deviceid
}
:
${
devicetoken
}
`
;
if
(
that
.
topicstore
.
addTopic
(
outtopic1
,
client
.
nodeid
))
{
if
(
DEBUG
)
console
.
log
(
'----- subscribe : '
+
outtopic1
)
that
.
mqttclient
.
subscribe
(
outtopic1
);
}
if
(
DEBUG
)
{
console
.
log
(
'registerfeedwatcher ---------------------------'
);
console
.
log
(
that
.
topicstore
.
getRawData
());
}
});
this
.
flowemitter
.
on
(
'deregisterfeedwatcher'
,
function
(
client
){
let
deviceid
=
client
.
deviceid
;
let
devicetoken
=
client
.
devicetoken
;
let
outtopic1
=
`@tap/feed/updated/
${
deviceid
}
:
${
devicetoken
}
`
;
if
(
that
.
topicstore
.
delTopic
(
outtopic1
,
client
.
nodeid
))
{
if
(
DEBUG
)
console
.
log
(
'----- unsubscribe : '
+
outtopic1
)
that
.
mqttclient
.
unsubscribe
(
outtopic1
);
}
if
(
DEBUG
)
{
console
.
log
(
'deregisterfeedwatcher ---------------------------'
);
console
.
log
(
that
.
topicstore
.
getRawData
());
}
});
this
.
flowemitter
.
on
(
'registershadowlistener'
,
function
(
client
){
this
.
flowemitter
.
on
(
'registershadowlistener'
,
function
(
client
){
let
deviceid
=
client
.
deviceid
;
let
deviceid
=
client
.
deviceid
;
let
devicetoken
=
client
.
devicetoken
;
let
devicetoken
=
client
.
devicetoken
;
...
...
flowemitter.js
View file @
18ebc7d4
...
@@ -12,6 +12,16 @@ const FlowEmitter = function(param = {}) {
...
@@ -12,6 +12,16 @@ const FlowEmitter = function(param = {}) {
FlowEmitter
.
prototype
.
start
=
function
()
{
FlowEmitter
.
prototype
.
start
=
function
()
{
let
that
=
this
;
let
that
=
this
;
this
.
red
.
events
.
on
(
`
${
that
.
channelID
}
-registerfeedwatcher`
,
function
(
client
)
{
that
.
emit
(
'registerfeedwatcher'
,
client
);
});
this
.
red
.
events
.
on
(
`
${
that
.
channelID
}
-deregisterfeedwatcher`
,
function
(
client
)
{
that
.
emit
(
'deregisterfeedwatcher'
,
client
);
//that.emit('startcountdownreset');
});
this
.
red
.
events
.
on
(
`
${
that
.
channelID
}
-registershadowlistener`
,
function
(
client
)
{
this
.
red
.
events
.
on
(
`
${
that
.
channelID
}
-registershadowlistener`
,
function
(
client
)
{
that
.
emit
(
'registershadowlistener'
,
client
);
that
.
emit
(
'registershadowlistener'
,
client
);
});
});
...
...
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