Skip to content

Commit 15c9966

Browse files
committed
Transleted "Full example"
1 parent ada8891 commit 15c9966

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

5-network/12-server-sent-events/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ eventSource.addEventListener('leave', event => {
198198
});
199199
```
200200

201-
## Full example
201+
## Пример
202202

203-
Here's the server that sends messages with `1`, `2`, `3`, then `bye` and breaks the connection.
203+
В этом примере сервер посылает сообщения `1`, `2`, `3`, затем `пока-пока` и разрывает соединение.
204204

205-
Then the browser automatically reconnects.
205+
После этого браузер автоматически восстанавливает соединение.
206206

207207
[codetabs src="eventsource"]
208208

5-network/12-server-sent-events/eventsource.view/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@
22
<script>
33
let eventSource;
44

5-
function start() { // when "Start" button pressed
5+
function start() { // когда нажата кнопка "Старт"
66
if (!window.EventSource) {
7-
// IE or an old browser
8-
alert("The browser doesn't support EventSource.");
7+
// Internet Explorer или устаревшие браузеры
8+
alert("Ваш браузер не поддерживает EventSource.");
99
return;
1010
}
1111

1212
eventSource = new EventSource('digits');
1313

1414
eventSource.onopen = function(e) {
15-
log("Event: open");
15+
log("Событие: open");
1616
};
1717

1818
eventSource.onerror = function(e) {
19-
log("Event: error");
19+
log("Событие: error");
2020
if (this.readyState == EventSource.CONNECTING) {
21-
log(`Reconnecting (readyState=${this.readyState})...`);
21+
log(`Переподключение (readyState=${this.readyState})...`);
2222
} else {
23-
log("Error has occured.");
23+
log("Произошла ошибка.");
2424
}
2525
};
2626

2727
eventSource.addEventListener('bye', function(e) {
28-
log("Event: bye, data: " + e.data);
28+
log("Событие: bye, данные: " + e.data);
2929
});
3030

3131
eventSource.onmessage = function(e) {
32-
log("Event: message, data: " + e.data);
32+
log("Событие: message, данные: " + e.data);
3333
};
3434
}
3535

36-
function stop() { // when "Stop" button pressed
36+
function stop() { // когда нажата кнопка "Стоп"
3737
eventSource.close();
38-
log("eventSource.close()");
38+
log("Соединение закрыто");
3939
}
4040

4141
function log(msg) {
@@ -44,7 +44,7 @@
4444
}
4545
</script>
4646

47-
<button onclick="start()">Start</button> Press the "Start" to begin.
47+
<button onclick="start()">Старт</button> Нажмите кнопку "Старт" для начала
4848
<div id="logElem" style="margin: 6px 0"></div>
4949

50-
<button onclick="stop()">Stop</button> "Stop" to finish.
50+
<button onclick="stop()">Стоп</button> Чтобы закончить, нажмите "Стоп".

5-network/12-server-sent-events/eventsource.view/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function onDigits(req, res) {
1717
i++;
1818

1919
if (i == 4) {
20-
res.write('event: bye\ndata: bye-bye\n\n');
20+
res.write('event: bye\ndata: пока-пока\n\n');
2121
clearInterval(timer);
2222
res.end();
2323
return;

0 commit comments

Comments
 (0)