HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
WebSocket WebSocket(
in DOMString url,
in optional DOMString protocols
);
WebSocket WebSocket(
in DOMString url,
in optional DOMString[] protocols
);
Feature: Simple chat
In order to websocket's challenge
As a presenter
I will create a simple chat
Scenario: At the beginning every user can select their name
Given New user
When try to connect to the chat
Then user can select his name
Scenario: New message
Given user which was already connected to the chat
And several users was already connected to the chat
When user enter a new message
Then all users will receive message
Scenario: Message history
Given New user
And History is not empty
When Use connect to the chat
Then User will recieve entire message history
Scenario: Close connection
Given User which was already connected to the chat
When a user closes the browser window
Then server will post another system message to the console that a user has disconnected.
input.keydown(function(e) { var msg; if (e.keyCode === 13) { msg = $(this).val(); if (!msg) return; connection.send(msg); $(this).val("");
}
var buffer = new ArrayBuffer(16)
var dv = new DataView(buffer, 8, 4)
dv.setUint16(2, 0x1337)
dv.getInt8(2) -> 0x13
var arr = new Int32Array(buffer)
arr[2] === ? Blob Blob(
[optional] Array parts,
[optional] BlobPropertyBag properties
);
Blob slice(
optional long long start,
optional long long end,
optional DOMString contentType
};
opcode |
meaning |
0 |
Continuation Frame |
1 |
Text Frame |
2 |
Binary Frame |
8 |
Connection Close Frame |
9 |
Ping Frame |
10 |
Pong Frame |