You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 5-network/12-server-sent-events/article.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,38 +85,38 @@ let source = new EventSource("https://another-site.com/events", {
85
85
Please see the chapter <info:fetch-crossorigin> for more details about cross-domain headers.
86
86
87
87
88
-
## Reconnection
88
+
## Переподключение
89
89
90
-
Upon creation, `new EventSource`connects to the server, and if the connection is broken -- reconnects.
90
+
После создания, `new EventSource`подключается к серверу и, если соединение обрывается, -- переподключается.
91
91
92
-
That's very convenient, as we don't have to care about it.
92
+
Это очень удобно, так как нам не приходится беспокоиться об этом.
93
93
94
94
There's a small delay between reconnections, a few seconds by default.
95
95
96
-
The server can set the recommended delay using`retry:`in response (in milliseconds):
96
+
Сервер может выставить рекомендуемую задержку, указав в ответе`retry:`(в милисекундах):
97
97
98
98
```js
99
99
retry:15000
100
-
data:Hello, I set the reconnection delay to 15seconds
100
+
data:Привет, я выставил задержку переподключения в 15секунд
101
101
```
102
102
103
-
The`retry:`may come both together with some data, or as a standalone message.
103
+
Поле`retry:`может посылаться как вместе с данными, так и отдельным сообщением.
104
104
105
-
The browser should wait that much before reconnect. If the network connection is lost, the browser may wait till it's restored, and then retry.
105
+
Браузер должен быть подождать окончания задержки перед попыткой переподключения. Если потеряно подключение к интернету, бразуер может дождаться его востанновления и затем попытаться переподключиться.
106
106
107
-
-If the server wants the browser to stop reconnecting, it should respond with HTTP status 204.
108
-
-If the browser wants to close the connection, it should call`eventSource.close()`:
107
+
-Если сервер хочет остановить попытки переподключения, он должен ответить со статусом 204.
108
+
-Если браузер хочет прекратить соединение, он может вызвать`eventSource.close()`:
109
109
110
110
```js
111
111
let eventSource =newEventSource(...);
112
112
113
113
eventSource.close();
114
114
```
115
115
116
-
Also, there will be no reconnection if the response has an incorrect `Content-Type`or its HTTP status differs from 301, 307, 200 and 204. The connection the `"error"` event is emitted, and the browser won't reconnect.
116
+
Также переподключение не произойдет, если в ответе указан неверный `Content-Type`или его статус отличается от 301, 307, 200 и 204. The connection the `"error"` event is emitted, and the browser won't reconnect.[???]
117
117
118
118
```smart
119
-
There's no way to "reopen" a closed connection. If we'd like to connect again, just create a new `EventSource`.
119
+
Переоткрыть закрытое соединение невозможно. Если необходимо снова подключиться, объявите новый `EventSource`.
0 commit comments