Expose parser error events to the user.

This commit is contained in:
James Coglan
2013-05-02 00:12:56 +01:00
parent 30d3eda575
commit 459499d6d6
3 changed files with 8 additions and 6 deletions
+7
View File
@@ -18,6 +18,13 @@ var API = function() {
this._parser.on('message', function(e) { self._receiveMessage(e.data) });
this._parser.on('close', function(e) { self._finalize(e.reason, e.code) });
this._parser.on('error', function(error) {
var event = new Event('error', {message: error.message});
event.initEvent('error', false, false);
this.dispatchEvent(event);
});
this.on('error', function() {});
this._parser.messages.on('drain', function() {
self.emit('drain');
});
-5
View File
@@ -94,11 +94,6 @@ JS.ENV.ClientSpec = JS.Test.describe("Client", function() { with(this) {
check_protocol("echo")
}})
it("cannot open a connection with unacceptable protocols", function() { with(this) {
open_socket(socket_url, ["foo"])
check_closed()
}})
it("can close the connection", function() { with(this) {
open_socket(socket_url, protocols)
close_socket()