Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1x 1x 1x 876x 876x 876x 876x 876x 876x 1x 1x 12x 12x 12x 12x 12x 5x 12x 12x 1x | 'use strict'
/*
* Copyright (c) 2013-2021 node-coap contributors.
*
* node-coap is licensed under an MIT +no-false-attribs license.
* All rights not explicitly granted in the MIT license are reserved.
* See the included LICENSE file for more details.
*/
var Readable = require('readable-stream').Readable
, util = require('util')
, pktToMsg = require('./helpers').packetToMessage
function IncomingMessage(packet, rsinfo, outSocket) {
Readable.call(this)
pktToMsg(this, packet)
this.rsinfo = rsinfo
this.outSocket = outSocket
this._packet = packet
this._payloadIndex = 0
}
util.inherits(IncomingMessage, Readable)
IncomingMessage.prototype._read = function(size) {
var end = this._payloadIndex + size
, start = this._payloadIndex
, payload = this._packet.payload
, buf = null
if (start < payload.length)
buf = payload.slice(start, end)
this._payloadIndex = end
this.push(buf)
}
module.exports = IncomingMessage
|