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-10 03:26:33 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7b0e118c0f56b86116a27bd263deb7910fe1c7da
7b0e118c
1 parent
8bccae8a
feat. hub control logic going dev
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
server/src/api/hub/hub.ctrl.js
server/src/api/hub/hub.ctrl.js
View file @
7b0e118
...
...
@@ -3,26 +3,20 @@ const Hub = require('../../models/hub');
const
Mqtt
=
require
(
'../../lib/MqttModule'
);
exports
.
hubConnect
=
async
(
ctx
)
=>
{
const
{
host
,
port
,
hubId
,
topic
}
=
ctx
.
request
.
body
;
const
{
host
,
port
,
hubId
}
=
ctx
.
request
.
body
;
const
hub
=
{
hubId
,
hosting
:
{
const
hosting
=
{
host
,
port
}
};
Mqtt
.
mqttOn
(
hosting
);
await
Hub
.
findOneAndUpdate
({
hubId
},
hub
,
{
},
{
hosting
},
{
upsert
:
true
});
const
client
=
Mqtt
.
mqttOn
({
host
,
port
});
Mqtt
.
mqttSubscribe
(
client
,
topic
);
ctx
.
body
=
'host :'
+
host
;
ctx
.
status
=
200
;
}
...
...
Please
register
or
login
to post a comment