Skip to content

Commit

Permalink
connection: send() as write
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Sep 29, 2010
1 parent 39d1919 commit a5dead8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

### Writing

conn.send('Hello, World')
conn.write('Hello, World');

### Closure

Expand Down
6 changes: 5 additions & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ Connection.prototype.send = function(payload) {
var w = new framing.MessageWriter(this.socket,
(payload.constructor === Buffer) ? 'binary' : 'text');
w.end(payload);
return !(socket._writeQueue && socket._writeQueue.length > 0);
return !(this.socket._writeQueue && this.socket._writeQueue.length > 0);
};

Connection.prototype.write = function() {
return this.send.apply(this, arguments);
};

Connection.prototype.end = function() {
Expand Down
4 changes: 2 additions & 2 deletions speedtest/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ spacesocket.attach(server, function(conn) {
if (conn.protocol === 'ping') {
conn.on('data', function(msg) {
if (msg === 'ping')
conn.send('pong');
conn.write('pong');
});
} else if (conn.protocol === 'download') {
var sender = function() {
while(conn.send(dummyData)) { }
while(conn.write(dummyData)) { }
};
conn.on('data', function(msg) {
var duration = parseInt(msg, 10);
Expand Down

0 comments on commit a5dead8

Please sign in to comment.