VoIP apps can send payloads up to 4096 bytes

This commit is contained in:
Andrew Naylor 2015-03-01 14:14:41 +00:00
Родитель 0a123083cb
Коммит 3ebd0c4810
3 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -16,6 +16,8 @@ Options:
- `production` {Boolean} Specifies which environment to connect to: Production (if true) or Sandbox - The hostname will be set automatically. (Defaults to NODE_ENV == "production", i.e. false unless the NODE_ENV environment variable is set accordingly)
- `voip` {Boolean} Enable when you are using a VoIP certificate to enable paylods up to 4096 bytes.
- `port` {Number} Gateway port (Defaults to: `2195`)
- `rejectUnauthorized` {Boolean} Reject Unauthorized property to be passed through to tls.connect() (Defaults to `true`)

Просмотреть файл

@ -56,6 +56,7 @@ function Connection (options) {
pfx: null,
passphrase: null,
production: (process.env.NODE_ENV === "production"),
voip: false,
address: null,
port: 2195,
rejectUnauthorized: true,
@ -703,8 +704,9 @@ Connection.prototype.transmitNotification = function(socket, notification) {
Connection.prototype.validNotification = function (notification, recipient) {
var messageLength = notification.length();
if (messageLength > 2048) {
var maxLength = (this.options.voip ? 4096 : 2048);
if (messageLength > maxLength) {
util.setImmediate(function () {
this.raiseError(Errors['invalidPayloadSize'], notification, recipient);
this.emit('transmissionError', Errors['invalidPayloadSize'], notification, recipient);

Просмотреть файл

@ -443,5 +443,13 @@ describe("Connection", function() {
expect(connection.validNotification(notification)).to.equal(false);
});
});
describe("VoIP flag set", function() {
it("allows longer payload", function() {
var connection = Connection({"voip": true});
var notification = { length: function() { return 4096; }};
expect(connection.validNotification(notification)).to.equal(true);
});
});
});
});