Compare commits

...

5 Commits

Author SHA1 Message Date
James Coglan adee8ba51c Bump version to 0.4.1. 2012-02-26 19:00:04 +00:00
James Coglan 3675cfb798 Treat anything but a Buffer as a text message in WebSocket#send. 2012-02-25 09:49:53 +00:00
James Coglan 1222308201 Return boolean from EventSource.send(). 2012-02-16 23:15:16 +00:00
James Coglan 8c9ae84740 Treat numbers as strings when passed to Socket.send(). 2012-02-16 23:09:29 +00:00
James Coglan d404c78c46 Add items to .npmignore. 2012-02-13 12:43:12 +00:00
6 changed files with 42 additions and 10 deletions
+2
View File
@@ -1,4 +1,6 @@
.git
.gitignore
.npmignore
.redcar
.travis.yml
node_modules
+5
View File
@@ -1,3 +1,8 @@
=== 0.4.1 / 2012-02-26
* Treat anything other than a Buffer as a string when calling send()
=== 0.4.0 / 2012-02-13
* Add ping() method to server-side WebSocket and EventSource
+7 -2
View File
@@ -62,7 +62,9 @@ var instance = {
DEFAULT_RETRY: 5,
send: function(message, options) {
message = message.replace(/(\r\n|\r|\n)/g, '$1data: ');
if (this.readyState !== API.OPEN) return false;
message = String(message).replace(/(\r\n|\r|\n)/g, '$1data: ');
options = options || {};
var frame = '';
@@ -72,7 +74,10 @@ var instance = {
try {
this._stream.write(frame, 'utf8');
} catch (e) {}
return true;
} catch (e) {
return false;
}
},
ping: function() {
+2
View File
@@ -43,6 +43,8 @@ var API = {
if (this.readyState === API.CLOSED)
return false;
if (!(data instanceof Buffer)) data = String(data);
var frame = this._parser.frame(data, type, errorType);
try {
this._stream.write(frame, 'binary');
+1 -1
View File
@@ -4,7 +4,7 @@
, "author" : "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)"
, "keywords" : ["websocket", "eventsource"]
, "version" : "0.4.0"
, "version" : "0.4.1"
, "engines" : {"node": ">=0.4.0"}
, "main" : "./lib/faye/websocket"
, "devDependencies" : {"jsclass": ""}
+25 -7
View File
@@ -60,13 +60,13 @@ JS.ENV.WebSocketSteps = JS.Test.asyncSteps({
callback()
},
send_message: function(callback) {
this._ws.send("I expect this to be echoed")
send_message: function(message, callback) {
this._ws.send(message)
setTimeout(callback, 100)
},
check_response: function(callback) {
this.assertEqual( "I expect this to be echoed", this._message )
check_response: function(message, callback) {
this.assertEqual( message, this._message )
callback()
},
@@ -116,8 +116,26 @@ JS.ENV.ClientSpec = JS.Test.describe("Client", function() { with(this) {
it("can send and receive messages", function() { with(this) {
listen_for_message()
send_message()
check_response()
send_message("I expect this to be echoed")
check_response("I expect this to be echoed")
}})
it("sends numbers as strings", function() { with(this) {
listen_for_message()
send_message(13)
check_response("13")
}})
it("sends booleans as strings", function() { with(this) {
listen_for_message()
send_message(false)
check_response("false")
}})
it("sends arrays as strings", function() { with(this) {
listen_for_message()
send_message([13,14,15])
check_response("13,14,15")
}})
}})
@@ -129,7 +147,7 @@ JS.ENV.ClientSpec = JS.Test.describe("Client", function() { with(this) {
it("cannot send and receive messages", function() { with(this) {
listen_for_message()
send_message()
send_message("I expect this to be echoed")
check_no_response()
}})
}})