Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90b8c9d23a | |||
| c3ac50931e | |||
| 5f6873ebc0 | |||
| 309b5651a7 |
@@ -96,6 +96,10 @@ var instance = {
|
||||
return false;
|
||||
},
|
||||
|
||||
pong: function() {
|
||||
return false;
|
||||
},
|
||||
|
||||
close: function(reason, code) {
|
||||
if (this.readyState !== 1) return false;
|
||||
this.readyState = 3;
|
||||
|
||||
@@ -169,6 +169,12 @@ var instance = {
|
||||
return this.frame(message, 'ping');
|
||||
},
|
||||
|
||||
pong: function(message) {
|
||||
if (this.readyState > 1) return false;
|
||||
message = message ||'';
|
||||
return this.frame(message, 'pong');
|
||||
},
|
||||
|
||||
close: function(reason, code) {
|
||||
reason = reason || '';
|
||||
code = code || this.ERRORS.normal_closure;
|
||||
|
||||
@@ -191,6 +191,30 @@ test.describe("Hybi", function() { with(this) {
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("pong", function() { with(this) {
|
||||
it("does not write to the socket", function() { with(this) {
|
||||
expect(driver().io, "emit").exactly(0)
|
||||
driver().pong()
|
||||
}})
|
||||
|
||||
it("returns true", function() { with(this) {
|
||||
assertEqual( true, driver().pong() )
|
||||
}})
|
||||
|
||||
it("queues the pong until the handshake has been sent", function() { with(this) {
|
||||
expect(driver().io, "emit").given("data", buffer(
|
||||
"HTTP/1.1 101 Switching Protocols\r\n" +
|
||||
"Upgrade: websocket\r\n" +
|
||||
"Connection: Upgrade\r\n" +
|
||||
"Sec-WebSocket-Accept: JdiiuafpBKRqD7eol0y4vJDTsTs=\r\n" +
|
||||
"\r\n"))
|
||||
expect(driver().io, "emit").given("data", buffer([0x8a, 0]))
|
||||
|
||||
driver().pong()
|
||||
driver().start()
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("close", function() { with(this) {
|
||||
it("does not write anything to the socket", function() { with(this) {
|
||||
expect(driver().io, "emit").exactly(0)
|
||||
@@ -425,6 +449,17 @@ test.describe("Hybi", function() { with(this) {
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("pong", function() { with(this) {
|
||||
it("writes a pong frame to the socket", function() { with(this) {
|
||||
driver().pong("mic check")
|
||||
assertEqual([0x8a, 0x09, 0x6d, 0x69, 0x63, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b], collector().bytes)
|
||||
}})
|
||||
|
||||
it("returns true", function() { with(this) {
|
||||
assertEqual(true, driver().pong())
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("close", function() { with(this) {
|
||||
it("writes a close frame to the socket", function() { with(this) {
|
||||
driver().close("<%= reasons %>", 1003)
|
||||
@@ -498,6 +533,17 @@ test.describe("Hybi", function() { with(this) {
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("pong", function() { with(this) {
|
||||
it("does not write to the socket", function() { with(this) {
|
||||
expect(driver().io, "emit").exactly(0)
|
||||
driver().pong()
|
||||
}})
|
||||
|
||||
it("returns false", function() { with(this) {
|
||||
assertEqual( false, driver().pong() )
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("close", function() { with(this) {
|
||||
it("does not write to the socket", function() { with(this) {
|
||||
expect(driver().io, "emit").exactly(0)
|
||||
@@ -558,6 +604,17 @@ test.describe("Hybi", function() { with(this) {
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("pong", function() { with(this) {
|
||||
it("does not write to the socket", function() { with(this) {
|
||||
expect(driver().io, "emit").exactly(0)
|
||||
driver().pong()
|
||||
}})
|
||||
|
||||
it("returns false", function() { with(this) {
|
||||
assertEqual( false, driver().pong() )
|
||||
}})
|
||||
}})
|
||||
|
||||
describe("close", function() { with(this) {
|
||||
it("does not write to the socket", function() { with(this) {
|
||||
expect(driver().io, "emit").exactly(0)
|
||||
|
||||
Reference in New Issue
Block a user