Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coap

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coap - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0

4

lib/helpers.js

@@ -231,1 +231,5 @@ /*

}
module.exports.isBoolean = function isBoolean(n) {
return typeof(n) === 'boolean';
}

@@ -24,2 +24,5 @@ /*

, maxPacketSize: 1280
// true: always send CoAP ACK messages, even for non confirmabe packets
// false: only send CoAP ACK messages for confirmabe packets
, sendAcksForNonConfirmablePackets: true
}

@@ -26,0 +29,0 @@ var defaultTiming = JSON.parse(JSON.stringify(p))

@@ -29,2 +29,3 @@ /*

, isNumeric = require('./helpers').isNumeric
, isBoolean = require('./helpers').isBoolean
, middlewares = require('./middlewares')

@@ -70,2 +71,5 @@ , debug = require('debug')('CoAP Server')

if (!isBoolean(this._options.sendAcksForNonConfirmablePackets)) {
this._options.sendAcksForNonConfirmablePackets = parameters.sendAcksForNonConfirmablePackets
}
this._middlewares.push(middlewares.handleServerRequest)

@@ -294,6 +298,9 @@

packet, packet.ack || !packet.confirmable), buf)
buf.sender = sender
sender.send(buf, packet.ack || packet.reset || packet.confirmable === false)
if (that._options.sendAcksForNonConfirmablePackets || packet.confirmable){
sender.send(buf, packet.ack || packet.reset || packet.confirmable === false)
} else {
debug('OMIT ACK PACKAGE')
}
})

@@ -300,0 +307,0 @@

2

package.json
{
"name": "coap",
"version": "0.15.0",
"version": "0.16.0",
"description": "A CoAP library for node modelled after 'http'",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -226,2 +226,3 @@ node-coap

biggyback response. Default 50.
* `sendAcksForNonConfirmablePackets`: Optional. Use this to suppress sending ACK messages for non-confirmable packages

@@ -228,0 +229,0 @@ #### Event: 'request'

@@ -955,3 +955,3 @@ /*

describe('piggyback timing option', function() {
describe('validate custom server options', function() {

@@ -979,5 +979,3 @@ var server

it('use custom piggyBackTimeout time', function(done) {
//GIVEN
var piggyBackTimeout = 10

@@ -993,7 +991,3 @@ var messages = 0;

})
//WHEN
send(new Buffer(3))
//THEN
setTimeout(function() {

@@ -1019,2 +1013,88 @@ expect(messages).to.eql(1)

it('use default sendAcksForNonConfirmablePackets', function(done) {
server = coap.createServer()
expect(server._options.sendAcksForNonConfirmablePackets).to.eql(true)
done()
})
it('define sendAcksForNonConfirmablePackets: true', function(done) {
server = coap.createServer({ sendAcksForNonConfirmablePackets: true })
expect(server._options.sendAcksForNonConfirmablePackets).to.eql(true)
done()
})
it('define sendAcksForNonConfirmablePackets: false', function(done) {
server = coap.createServer({ sendAcksForNonConfirmablePackets: false })
expect(server._options.sendAcksForNonConfirmablePackets).to.eql(false)
done()
})
it('define invalid sendAcksForNonConfirmablePackets setting', function(done) {
server = coap.createServer({ sendAcksForNonConfirmablePackets: 'moo' })
expect(server._options.sendAcksForNonConfirmablePackets).to.eql(true)
done()
})
function sendNonConfirmableMessage() {
var packet = {
confirmable: false
, messageId: 4242
, token: new Buffer(5)
}
send(generate(packet))
}
function sendConfirmableMessage() {
var packet = {
confirmable: true
, messageId: 4242
, token: new Buffer(5)
}
send(generate(packet))
}
it('should send ACK for non-confirmable message, sendAcksForNonConfirmablePackets=true', function(done) {
var messages = 0;
server = coap.createServer({ sendAcksForNonConfirmablePackets: true })
server.listen(port)
server.on('request', function(req, res) {
res.end('42')
})
client.on('message', function(msg) {
done()
})
sendNonConfirmableMessage()
})
it('should not send ACK for non-confirmable message, sendAcksForNonConfirmablePackets=false', function(done) {
var messages = 0;
server = coap.createServer({ sendAcksForNonConfirmablePackets: false })
server.listen(port)
server.on('request', function(req, res) {
res.end('42')
})
client.on('message', function(msg) {
messages++
})
sendNonConfirmableMessage()
setTimeout(function() {
expect(messages).to.eql(0)
done()
}, 30)
})
it('should send ACK for confirmable message, sendAcksForNonConfirmablePackets=true', function(done) {
var messages = 0;
server = coap.createServer({ sendAcksForNonConfirmablePackets: true })
server.listen(port)
server.on('request', function(req, res) {
res.end('42')
})
client.on('message', function(msg) {
done();
})
sendConfirmableMessage()
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc