1 / 8

WebSockets in HTML5

WebSockets in HTML5. Mark J Collins October 6 th , 2012. Browser – Server Communication. Handshaking. Request (from browser). GET /chat HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: localhost:8100 Origin: http://localhost:29781 Sec- WebSocket -Key: <request key>

fordon
Download Presentation

WebSockets in HTML5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WebSockets in HTML5 Mark J Collins October 6th, 2012

  2. Browser – Server Communication

  3. Handshaking Request (from browser) GET /chat HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: localhost:8100 Origin: http://localhost:29781 Sec-WebSocket-Key: <request key> Sec-WebSocket-Version: 13 Response (from server) HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: <response key>

  4. WebSocketProtocol (ws) • Opcodes: • 0x0 indicates this is a continuation frame • 0x1 specifies the payload contains text • 0x2 indicates a binary payload • 0x8 indicates the connection is being closed • 0x9 specifies the message is a ping • 0xA specifies the message is a pong

  5. Masking • For security reasons, all messages from the client should be masked • Messages from the server are not masked • A different masking key is provided in each message • Unmasking is done by XOR-ing the bytes for (inti = 0; i < length; i++) { payload[i] = (byte)(payload[i] ^ masks[i % 4]); }

  6. Solution Design

  7. Initial Server Design

  8. WebSocket Server Design • WsAgentConnection – manages the communication with an agent application • WsClientConnection – manages the communication with a client application

More Related