Skip to content

Commit

Permalink
fix(types): temporary paths for incorporating new types as known
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Feb 16, 2016
1 parent 9a87d09 commit 0b4a412
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
31 changes: 16 additions & 15 deletions lib/connection.js
Expand Up @@ -19,9 +19,7 @@ var EventEmitter = require('events').EventEmitter,
CloseFrame = require('./frames/close_frame'),
HeartbeatFrame = require('./frames/heartbeat_frame'),
OpenFrame = require('./frames/open_frame'),
TransportProvider = require('./transport'),

OpenFrameV2 = require('./frames').Open;
TransportProvider = require('./transport');



Expand Down Expand Up @@ -407,18 +405,20 @@ Connection.prototype._tryReceiveHeader = function(header) {
};

Connection.prototype._tryReceiveFrame = function() {
try {
var frame = FrameReader.read(this._buffer);
if (frame === undefined) {
//debug('Not enough frame');
} else {
//debug('Matched frame: ' + frame.constructor.name + ': ' + JSON.stringify(frame));
//debug(this._buffer.length + ' bytes left');
}
return frame;
} catch (e) {
console.warn(e.message);
var frame = FrameReader.read(this._buffer);
if (frame === undefined) {
//debug('Not enough frame');
} else {
//debug('Matched frame: ' + frame.constructor.name + ': ' + JSON.stringify(frame));
//debug(this._buffer.length + ' bytes left');
}
return frame;

// try {
// var frame = FrameReader.read(this._buffer);
// } catch (e) {
// console.warn(e.message);
// }
};

Connection.prototype._receiveAny = function() {
Expand All @@ -439,6 +439,7 @@ Connection.prototype._receiveAny = function() {
more = this._tryReceiveHeader();
continue;
}

frame = this._tryReceiveFrame();
if (frame) {
if (frame instanceof OpenFrame) {
Expand All @@ -459,7 +460,7 @@ Connection.prototype._ensureLocaleCompatibility = function(lhsLocales, rhsLocale
};

Connection.prototype._sendOpenFrame = function() {
this.sendFrame(new OpenFrameV2(this._params));
this.sendFrame(new OpenFrame(this._params));
};

Connection.prototype._processOpenFrame = function(frame) {
Expand Down
5 changes: 4 additions & 1 deletion lib/frames.js
Expand Up @@ -101,7 +101,10 @@ frames.readFrame = function(buffer) {
}

var frame = new framesByDescriptor[described.descriptor](described);
frame.channel = channel;
if (frameType === FrameType.AMQP) {
frame.channel = channel;
}

return frame;
};

Expand Down
4 changes: 1 addition & 3 deletions lib/session.js
Expand Up @@ -22,9 +22,7 @@ var EventEmitter = require('events').EventEmitter,
Link = require('./link'),
SenderLink = require('./sender_link'),
ReceiverLink = require('./receiver_link'),
Connection = require('./connection'),

BeginFrameV2 = require('./frames').Begin;
Connection = require('./connection');



Expand Down
14 changes: 11 additions & 3 deletions lib/types/known_type_converter.js
Expand Up @@ -18,9 +18,17 @@ function convertType(describedType) {
var descriptorStr = describedType.descriptor.toString();
var _len = knownTypes.length;
for (var _i = 0; _i < _len; ++_i) {
if (knownTypes[_i].prototype.Descriptor.name.toString() === descriptorStr ||
knownTypes[_i].prototype.Descriptor.code.toString() === descriptorStr) {
return knownTypes[_i].fromDescribedType(describedType);
var Type = knownTypes[_i];
if (Type.prototype.Descriptor) {
if (Type.prototype.Descriptor.name.toString() === descriptorStr ||
Type.prototype.Descriptor.code.toString() === descriptorStr) {
return Type.fromDescribedType(describedType);
}
} else if (Type.prototype.descriptor) {
if (Type.prototype.descriptor.name === descriptorStr ||
Type.prototype.descriptor.code === describedType.descriptor) {
return new Type(describedType);
}
}
}

Expand Down

0 comments on commit 0b4a412

Please sign in to comment.