Websocket Introduction
Before WebSocket appears, to dealing with 2-way data communications, we have some choices such as 'Polling'(輪詢), 'Long Polling'(長時間輪詢) or 'Silent Push Notification'(無聲推播).
But, the more 'Polling' we used, the more 'NetWork Request' we caused, and some of them won't even response a new data. Furthermore, sending too much 'Silent Push Notification' isn't that effective, because 'Notification' isn't received at once.
'Long Polling' is the best choice among them, it is the extended version of 'Polling' and will keep an effective link between server and client, but this is also the cons of it, every 'Network Request' will come up with a 'Http OverHead'(Http 開銷), and so, server will need extra maintainance for it's complexity.
This is why WebSocket was created, because it doesn't have any 'Http OverHead' protocols, and when client sends a WebSocket connection request to server, it'll create a 2-way connections stream to receive or send data/messages from any side (not through 'Network Request').