Skip to content

Commit

Permalink
[minor api] Allow Client.prototype.write to accept an Array in addt…
Browse files Browse the repository at this point in the history
…ion to an Object.
  • Loading branch information
indexzero committed Feb 12, 2013
1 parent b09412a commit bf93727
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/godot/net/client.js
Expand Up @@ -93,10 +93,14 @@ Client.prototype.remove = function (producer, id) {
// connection associated with this client.
//
Client.prototype.write = function (data) {
var message = JSON.stringify(data) + 'g!\n!t';
var message = !Array.isArray(data)
? JSON.stringify(data) + 'g!\n!t'
: data.map(function (d) {
return JSON.stringify(d) + 'g!\n!t';
});

if (this.type === 'tcp') {
this.socket.write(message)
this.socket.write(message);
}
else if (this.type === 'udp') {
message = new Buffer(message);
Expand Down

0 comments on commit bf93727

Please sign in to comment.