Skip to content
This repository was archived by the owner on Nov 28, 2018. It is now read-only.

Commit 497e742

Browse files
author
Tony Young
committed
Play nicer with RabbitMQ.
1 parent a300e9f commit 497e742

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

lib/frame.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,24 @@ Frame.prototype.build_frame = function(args, want_receipt) {
6464
Frame.prototype.as_string = function() {
6565
var self = this,
6666
header_strs = [],
67-
frame = null,
67+
frame = "",
6868
command = this.command,
6969
headers = this.headers,
7070
body = this.body;
7171

7272
for (var header in headers) {
73-
header_strs.push(header + ': ' + headers[header]);
73+
header_strs.push(header + ':' + headers[header]);
7474
}
7575

76-
frame = command + '\n' + header_strs.join('\n') + '\n\n' + body + '\x00';
76+
frame += command + "\n";
77+
frame += header_strs.join('\n');
78+
frame += "\n";
79+
80+
if(body)
81+
frame += '\n' + body + '\x00';
82+
83+
frame += '\n\x00';
84+
7785
return frame;
7886
};
7987

lib/stomp.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ function _connect(stomp) {
9898

9999
socket.on('connect', function() {
100100
log.debug('Connected to socket');
101-
if (utils.really_defined(stomp.login)
102-
&& utils.really_defined(stomp.passcode)) {
101+
if (utils.really_defined(stomp.login) &&
102+
utils.really_defined(stomp.passcode)) {
103103
stomp_connect(stomp, {login: stomp.login, passcode: stomp.passcode});
104104
}
105105
else {
@@ -117,8 +117,6 @@ function _connect(stomp) {
117117
var frames = buffer.split('\0\n');
118118
var parsed_frame = null;
119119
var _frame = null;
120-
buffer = frames.pop();
121-
122120
while (_frame = frames.shift()) {
123121
parsed_frame = parse_frame(_frame + '\0\n')
124122
stomp.handle_new_frame(parsed_frame);
@@ -138,6 +136,7 @@ function _connect(stomp) {
138136
log.debug('disconnected');
139137
if (error)
140138
log.error('Disconnected with error: ' + error);
139+
stomp.emit("disconnected");
141140
});
142141
};
143142

@@ -150,6 +149,7 @@ function stomp_connect(stomp, headers) {
150149
args['headers'] = headers;
151150

152151
var frame_to_send = _frame.build_frame(args);
152+
153153
send_frame(stomp, frame_to_send);
154154
log.debug('Connected to STOMP');
155155
};

0 commit comments

Comments
 (0)