Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-05-11 21:50:09 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
010bf8f3ca036d9c94665038a5cb7c49a5d517ae
010bf8f3
1 parent
bbfe67ff
feat. server on -> all of mqtt client on Util
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
server/src/util/MqttServer.js
server/src/util/MqttServer.js
0 → 100644
View file @
010bf8f
const
Mqtt
=
require
(
'../lib/MqttModule'
);
const
DataProcess
=
require
(
'../lib/DataProcess'
);
const
Hub
=
require
(
'../models/hub'
);
const
Bottle
=
require
(
'../models/bottle'
);
exports
.
on
=
async
()
=>
{
await
subscribeOn
();
console
.
log
(
'\x1b[1;34mMQTT Server On\x1b[0m'
);
};
const
subscribeOn
=
async
()
=>
{
const
bottleList
=
await
Bottle
.
find
();
bottleList
.
forEach
(
async
(
bottle
)
=>
{
const
topic
=
'bottle/'
+
bottle
.
getBottleId
()
+
'/bts'
;
const
hub
=
await
Hub
.
findByHubId
(
bottle
.
getHubId
());
const
client
=
await
Mqtt
.
mqttOn
(
hub
.
getHubHost
(),
DataProcess
.
dataPublish
);
Mqtt
.
mqttSubscribe
(
client
,
topic
);
})
};
\ No newline at end of file
Please
register
or
login
to post a comment