Fix StackOverflow avoidance (#4)
This commit is contained in:
1 parent
df74989fdd
commit
bf4e69e2ce
3 files changed
+454
-432
No files matched your search
@@ -705,7 +705,7 @@ Uint8Array.prototype.charCodeAt = function(a, b) {
|
|||||||
this.client = false;
|
this.client = false;
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
/* if keep_alive is less than the ping interval we need to use
|
/* if keep_alive is less than the ping interval we need to use
|
||||||
a shorter ping interval, otherwise we'll just time out! */ this.ping_interval = this.keep_alive < this.C.PING_INTERVAL ? this.keep_alive - 5 : this.C.PING_INTERVAL;
|
a shorter ping interval, otherwise we'll just time out! */ this.ping_interval = this.keep_alive < this.C.PING_INTERVAL ? this.keep_alive - 5 : this.C.PING_INTERVAL;
|
||||||
this.protocol_name = options.protocol_name || "MQTT";
|
this.protocol_name = options.protocol_name || "MQTT";
|
||||||
this.protocol_level = options.protocol_level || C.PROTOCOL_LEVEL;
|
this.protocol_level = options.protocol_level || C.PROTOCOL_LEVEL;
|
||||||
if (typeof this.client_id == "string") {
|
if (typeof this.client_id == "string") {
|
||||||
@@ -926,15 +926,13 @@ MQTT.prototype.packetHandler = function(data) {
|
|||||||
this.partData = data;
|
this.partData = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get the data for this packet
|
// Allow zero-size pData, but detect if its indexes
|
||||||
var pData = data.slice(1 + dLen.lenBy, pLen);
|
// will go out of bounds.
|
||||||
|
if (1 + dLen.lenBy >= data.length) {
|
||||||
// Avoid an infinite data emit loop
|
|
||||||
if (pData.length < 1) {
|
|
||||||
this.partData = data;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Get the data for this packet
|
||||||
|
var pData = data.slice(1 + dLen.lenBy, pLen);
|
||||||
// more than one packet? re-emit it so we handle it later
|
// more than one packet? re-emit it so we handle it later
|
||||||
if (data.length > pLen) {
|
if (data.length > pLen) {
|
||||||
this.client.emit("data", data.slice(pLen, data.length));
|
this.client.emit("data", data.slice(pLen, data.length));
|
||||||
@@ -1091,11 +1089,11 @@ MQTT.prototype.packetHandler = function(data) {
|
|||||||
this.client = false;
|
this.client = false;
|
||||||
};
|
};
|
||||||
/** Publish message using specified topic.
|
/** Publish message using specified topic.
|
||||||
opts = {
|
opts = {
|
||||||
retain: bool // the server should retain this message and send it out again to new subscribers
|
retain: bool // the server should retain this message and send it out again to new subscribers
|
||||||
dup : bool // indicate the message is a duplicate because original wasn't ACKed (QoS > 0 only)
|
dup : bool // indicate the message is a duplicate because original wasn't ACKed (QoS > 0 only)
|
||||||
}
|
}
|
||||||
*/ MQTT.prototype.publish = function(topic, message, opts) {
|
*/ MQTT.prototype.publish = function(topic, message, opts) {
|
||||||
if (!this.client) return;
|
if (!this.client) return;
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
try {
|
try {
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "flic2hass",
|
"name": "flic2hass",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "flic2hass",
|
"name": "flic2hass",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.1.62",
|
"@swc/cli": "^0.1.62",
|
||||||
|
|||||||
+441
-417
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user