Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pi.hub
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
iot
pi.hub
Commits
14eab3de
Commit
14eab3de
authored
Jul 05, 2017
by
Martin Kotula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted to hub contract
parent
83dda3db
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
UI.Web.Dashboard/src/services/mqttListener.js
+10
-2
No files found.
UI.Web.Dashboard/src/services/mqttListener.js
View file @
14eab3de
...
@@ -17,11 +17,19 @@ define(["app/config", "app/events", "mqtt", "lodash", "knockout", "knockout-post
...
@@ -17,11 +17,19 @@ define(["app/config", "app/events", "mqtt", "lodash", "knockout", "knockout-post
try
{
try
{
console
.
debug
(
"Mqtt message received: "
+
message
.
toString
());
console
.
debug
(
"Mqtt message received: "
+
message
.
toString
());
var
messageBody
=
JSON
.
parse
(
message
.
toString
());
var
messageBody
=
JSON
.
parse
(
message
.
toString
());
if
(
messageBody
.
id
===
undefined
||
messageBody
.
isOccupied
===
undefined
){
if
(
messageBody
.
object
===
undefined
||
messageBody
.
object
.
sensorid
===
undefined
||
messageBody
.
object
.
isbusy
===
undefined
){
throw
"InvalidMessageFormat"
;
throw
"InvalidMessageFormat"
;
}
}
ko
.
postbox
.
publish
(
events
.
sensorUpdate
,
_
.
merge
(
messageBody
,
{
timestamp
:
new
Date
()}));
var
model
=
{
id
:
messageBody
.
object
.
sensorid
,
isOccupied
:
messaegeBody
.
object
.
isbusy
,
timestamp
:
new
Date
()
};
ko
.
postbox
.
publish
(
events
.
sensorUpdate
,
model
);
}
}
catch
(
e
){
catch
(
e
){
console
.
error
(
"Failed to parse message into JSON: ["
+
message
.
toString
()
+
"]: "
+
e
);
console
.
error
(
"Failed to parse message into JSON: ["
+
message
.
toString
()
+
"]: "
+
e
);
...
...
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