Compare commits

...

8 Commits

Author SHA1 Message Date
James Coglan 90d039e371 Bump version to 0.4.2. 2012-04-06 18:57:29 +01:00
James Coglan b42cdf741d Add error code 1011. 2012-04-06 13:52:21 +01:00
James Coglan bd7c52dfa2 Use / as the default path if the client URI has no path. 2012-04-01 22:57:16 +01:00
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
8 changed files with 59 additions and 20 deletions
+2
View File
@@ -1,4 +1,6 @@
.git
.gitignore
.npmignore
.redcar
.travis.yml
node_modules
+11
View File
@@ -1,3 +1,14 @@
=== 0.4.2 / 2012-04-06
* Add WebSocket error code 1011.
* Handle URLs with no path correctly by sending 'GET /'
=== 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');
+10 -9
View File
@@ -46,20 +46,21 @@ var instance = {
},
ERRORS: {
normal_closure: 1000,
going_away: 1001,
protocol_error: 1002,
unacceptable: 1003,
encoding_error: 1007,
policy_violation: 1008,
too_large: 1009,
extension_error: 1010
normal_closure: 1000,
going_away: 1001,
protocol_error: 1002,
unacceptable: 1003,
encoding_error: 1007,
policy_violation: 1008,
too_large: 1009,
extension_error: 1010,
unexpected_condition: 1011
},
FRAGMENTED_OPCODES: [0,1,2],
OPENING_OPCODES: [1,2],
ERROR_CODES: [1000,1001,1002,1003,1007,1008,1009,1010],
ERROR_CODES: [1000,1001,1002,1003,1007,1008,1009,1010,1011],
UTF8_MATCH: /^([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/,
+1 -1
View File
@@ -46,7 +46,7 @@ Handshake.prototype.requestData = function() {
var u = this._uri;
var headers = [
'GET ' + u.pathname + (u.search || '') + ' HTTP/1.1',
'GET ' + (u.pathname || '/') + (u.search || '') + ' HTTP/1.1',
'Host: ' + u.hostname + (u.port ? ':' + u.port : ''),
'Upgrade: websocket',
'Connection: Upgrade',
+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.2"
, "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()
}})
}})