Chapter 10: WebSockets
Socket.IO
client code and server side are JS (server is node.js). switches between websocket, ajax long polling, or flash polling
how can you attempt to prevent timeouts with websockets?
create a timer that will send empty messages on an interval to keep the connection active
how do you open a websocket connection?
instantiate the WebSocket object, and it automatically attempts to open asynchronously
web farm
multiple server handling incoming requests
websocket.ReadyState
CONNECTING = 0 Connection is not yet open. OPEN = 1 Connection is open and ready to communicate. CLOSING = 2 Connection is in the process of closing. CLOSED = 3 Connection is closed or couldn't be opened.
Do the WebSocket protocol and WebSocket API provide native support for load balancing in a web farm?
no
what 4 events do you implement on the websocket object?
onopen, onmessage, onerror, and onclose
WebSocket Protocol
provides a standardized way for the server to send content to the browser without being solicited by the client and to allow messages to be passed back and forth while keeping the connection open
long polling
replaced by websockets; client sends a request to the server, and if the server has information with which to respond, it responds. If the server doesn't have information with which to respond, the server keeps the connection open and doesn't respond until it has data. When the client receives the data, it sends another request to the server, and the sequence repeats itself
SignalR
websocket library that switches between long polling and websockets depending on what is available. For ASP.NET, client side is JS
where can you access the websocket object from?
window.
websocket url "protocol"
ws:// or wss://