fixes
This commit is contained in:
parent
d606fb7181
commit
e52705e012
4 changed files with 8 additions and 9 deletions
|
@ -1,8 +1,6 @@
|
|||
# WebSocket
|
||||
|
||||
The `WebSocket` protocol, described in the specification [RFC 6455](http://tools.ietf.org/html/rfc6455) provides a way to exchange data between browser and server via a persistent connection.
|
||||
|
||||
Once a websocket connection is established, both client and server may send the data to each other.
|
||||
The `WebSocket` protocol, described in the specification [RFC 6455](http://tools.ietf.org/html/rfc6455) provides a way to exchange data between browser and server via a persistent connection. The data can be passed in both directions as "packets", without breaking the connection and additional HTTP-requests.
|
||||
|
||||
WebSocket is especially great for services that require continuous data exchange, e.g. online games, real-time trading systems and so on.
|
||||
|
||||
|
@ -21,7 +19,7 @@ The `wss://` protocol not only encrypted, but also more reliable.
|
|||
|
||||
That's because `ws://` data is not encrypted, visible for any intermediary. Old proxy servers do not know about WebSocket, they may see "strange" headers and abort the connection.
|
||||
|
||||
On the other hand, `wss://` is WebSocket over TLS, (same as HTTPS is HTTP over TLS), the transport security layer encrypts the data at sender and decrypts at the receiver, so it passes encrypted through proxies. They can't see what's inside and let it through.
|
||||
On the other hand, `wss://` is WebSocket over TLS, (same as HTTPS is HTTP over TLS), the transport security layer encrypts the data at sender and decrypts at the receiver. So data packets are passed encrypted through proxies. They can't see what's inside and let them through.
|
||||
```
|
||||
|
||||
Once the socket is created, we should listen to events on it. There are totally 4 events:
|
||||
|
@ -38,7 +36,7 @@ Here's an example:
|
|||
let socket = new WebSocket("wss://javascript.info/article/websocket/demo/hello");
|
||||
|
||||
socket.onopen = function(e) {
|
||||
alert("[open] Connection established, send -> server");
|
||||
alert("[open] Connection established, send the data -> server");
|
||||
socket.send("My name is John");
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue