Skip to content
Permalink
Browse files

[minor api] Allow `Client.prototype.write` to accept an Array in addt…

…ion to an Object.
  • Loading branch information
indexzero committed Feb 12, 2013
1 parent b09412a commit bf93727e5520644542eb0b5a2cb8018ccc299ecb
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/godot/net/client.js
@@ -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);

0 comments on commit bf93727

Please sign in to comment.
You can’t perform that action at this time.