Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90d039e371 | |||
| b42cdf741d | |||
| bd7c52dfa2 | |||
| adee8ba51c | |||
| 3675cfb798 | |||
| 1222308201 | |||
| 8c9ae84740 | |||
| d404c78c46 |
@@ -1,4 +1,6 @@
|
||||
.git
|
||||
.gitignore
|
||||
.npmignore
|
||||
.redcar
|
||||
.travis.yml
|
||||
node_modules
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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})*$/,
|
||||
|
||||
|
||||
@@ -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
@@ -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": ""}
|
||||
|
||||
@@ -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()
|
||||
}})
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user