Skip to content

Commit

Permalink
Fixed an issue with arity (added to prototype, forgot to remove conne…
Browse files Browse the repository at this point in the history
…ction param), fixed disappearing _sendBody options
  • Loading branch information
ssafejava committed Aug 23, 2013
1 parent 173f77c commit 98db94b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib/amqp/constants-generated.js
node_modules/
.DS_Store
14 changes: 6 additions & 8 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ Connection.prototype.reconnect = function () {
this.channels[channel].state = 'closed';
}
debug("Connection lost, reconnecting...");
console.trace();
// Terminate socket activity
this.end();
this._connect();
Expand Down Expand Up @@ -603,17 +602,16 @@ Connection.prototype.sendHeader = function(channel, size, properties) {
serializer.serializeInt(b, 8, size); // byte size of body

// properties - first propertyFlags
var props = {'contentType': 'application/octet-stream'};
_.extend(props, properties);
properties = _.defaults(properties || {}, {contentType: 'application/octet-stream'});
var propertyFlags = 0;
for (var i = 0; i < classInfo.fields.length; i++) {
if (props[classInfo.fields[i].name]) propertyFlags |= 1 << (15-i);
if (properties[classInfo.fields[i].name]) propertyFlags |= 1 << (15-i);
}
serializer.serializeInt(b, 2, propertyFlags);
// now the actual properties.
serializer.serializeFields(b, classInfo.fields, props, false);
serializer.serializeFields(b, classInfo.fields, properties, false);

//serializeTable(b, props);
//serializeTable(b, properties);

var bodyEnd = b.used;

Expand All @@ -638,9 +636,9 @@ Connection.prototype._sendBody = function (channel, body, properties) {
var r = this._bodyToBuffer(body);
var props = r[0], buffer = r[1];

properties = _.extend(props, properties);
properties = _.extend(props || {}, properties);

this.sendHeader(this, channel, buffer.length, properties);
this.sendHeader(channel, buffer.length, properties);

var pos = 0, len = buffer.length;
while (len > 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var debugLevel = process.env['NODE_DEBUG_AMQP'] ? 1 : 0;

var DEBUG = debugLevel > 0 || true;
var DEBUG = debugLevel > 0;

module.exports = function debug () {
if (DEBUG) console.error.apply(null, arguments);
Expand Down
17 changes: 8 additions & 9 deletions lib/exchange.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict';
var events = require('events'),
util = require('util'),
net = require('net'),
tls = require('tls'),
fs = require('fs'),
_ = require('lodash'),
methods = require('./definitions').methods,
Channel = require('./channel'),
protocol;
var events = require('events');
var util = require('util');
var net = require('net');
var tls = require('tls');
var fs = require('fs');
var _ = require('lodash');
var methods = require('./definitions').methods;
var Channel = require('./channel');


var Exchange = module.exports = function Exchange (connection, channel, name, options, openCallback) {
Expand Down
1 change: 1 addition & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var Indicators = require('./constants').Indicators;
var FrameType = require('./constants').FrameType;
var definitions = require('./definitions');
var methodTable = definitions.methodTable;
var classes = definitions.classes;

// parser

Expand Down
2 changes: 1 addition & 1 deletion lib/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,4 @@ var serializer = module.exports = {
}
}
}
}
};
1 change: 1 addition & 0 deletions test/test-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ connection.addListener('ready', function () {
q.on('queueBindOk', function() {
q.on('basicConsumeOk', function () {
puts("publishing message");
debugger;
exchange.publish("message.text", body, {contentType: 'text/plain'});

setTimeout(function () {
Expand Down

0 comments on commit 98db94b

Please sign in to comment.