2
0
Files
node-red-contrib-mi-devices/dist/devices/gateway/GatewayMessage.js
2018-03-21 23:29:36 +01:00

31 lines
735 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class GatewayMessage {
constructor(raw) {
Object.assign(this, raw);
if (raw.port) {
this.port = parseInt(raw.port);
}
if (raw.data) {
this.data = JSON.parse(raw.data) || raw.data;
}
this.timestamp = +new Date;
}
isHeartbeat() {
return this.cmd === "heartbeat";
}
isIam() {
return this.cmd === "iam";
}
isGetIdListAck() {
return this.cmd === "get_id_list_ack";
}
isReadAck() {
return this.cmd === "read_ack";
}
isReport() {
return this.cmd === "report";
}
}
exports.GatewayMessage = GatewayMessage;