Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/node-red/node_modules/mqtt/lib/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
/**
* Module dependencies
*/
var xtend = require('xtend')
var Readable = require('readable-stream').Readable
var streamsOpts = { objectMode: true }
var defaultStoreOptions = {
clean: true
}
/**
* In-memory implementation of the message store
* This can actually be saved into files.
*
* @param {Object} [options] - store options
*/
function Store (options) {
if (!(this instanceof Store)) {
return new Store(options)
}
this.options = options || {}
// Defaults
this.options = xtend(defaultStoreOptions, options)
this._inflights = new Map()
}
/**
* Adds a packet to the store, a packet is
* anything that has a messageId property.
*
*/
Store.prototype.put = function (packet, cb) {
this._inflights.set(packet.messageId, packet)
if (cb) {
cb()
}
return this
}
/**
* Creates a stream with all the packets in the store
*
*/
Store.prototype.createStream = function () {
var stream = new Readable(streamsOpts)
var destroyed = false
var values = []
var i = 0
this._inflights.forEach(function (value, key) {
values.push(value)
})
stream._read = function () {
if (!destroyed && i < values.length) {
this.push(values[i++])
} else {
this.push(null)
}
}
stream.destroy = function () {
if (destroyed) {
return
}
var self = this
destroyed = true
setTimeout(function () {
self.emit('close')
}, 0)
}
return stream
}
/**
* deletes a packet from the store.
*/
Store.prototype.del = function (packet, cb) {
packet = this._inflights.get(packet.messageId)
if (packet) {
this._inflights.delete(packet.messageId)
cb(null, packet)
} else if (cb) {
cb(new Error('missing packet'))
}
return this
}
/**
* get a packet from the store.
*/
Store.prototype.get = function (packet, cb) {
packet = this._inflights.get(packet.messageId)
if (packet) {
cb(null, packet)
} else if (cb) {
cb(new Error('missing packet'))
}
return this
}
/**
* Close the store
*/
Store.prototype.close = function (cb) {
if (this.options.clean) {
this._inflights = null
}
if (cb) {
cb()
}
}
module.exports = Store
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0094 ]-- |