Skip to content

Commit 82dc883

Browse files
committed
Translated introduction
1 parent 56c7b5b commit 82dc883

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Server Sent Events
1+
# Посылаемые сервером события
22

3-
The [Server-Sent Events](https://html.spec.whatwg.org/multipage/comms.html#the-eventsource-interface) specification describes a built-in class `EventSource`, that keeps connection with the server and allows to receive events from it.
3+
Спецификация [Server-Sent Events](https://html.spec.whatwg.org/multipage/comms.html#the-eventsource-interface) описывает встроенный класс `EventSource`, который позволяет поддерживать соединение с сервером и получать от него события.
44

5-
Similar to `WebSocket`, the connection is persistent.
5+
Как и в случае с `WebSocket`, соединение постоянно.
66

7-
But there are several important differences:
7+
Но есть несколько важных различий:
88

99
| `WebSocket` | `EventSource` |
1010
|-------------|---------------|
11-
| Bi-directional: both client and server can exchange messages | One-directional: only server sends data |
12-
| Binary and text data | Only text |
13-
| WebSocket protocol | Regular HTTP |
11+
| Двунаправленность: и сервер, и клиент могут обмениваться сообщениями | Однонаправленность: данные посылает только сервер |
12+
| Бинарные и текстовые данные | Только текст |
13+
| Протокол WebSocket | Обычный HTTP |
1414

15-
`EventSource` is a less-powerful way of communicating with the server than `WebSocket`.
15+
`EventSource` не настолько мощный способ коммуникации с сервером, как `WebSocket`.
1616

17-
Why should one ever use it?
17+
Зачем нам его использовать?
1818

19-
The main reason: it's simpler. In many applications, the power of `WebSocket` is a little bit too much.
19+
Основная причина: он проще. Многим приложениям не требуется вся мощь `WebSocket`.
2020

21-
We need to receive a stream of data from server: maybe chat messages or market prices, or whatever. That's what `EventSource` is good at. Also it supports auto-reconnect, something we need to implement manually with `WebSocket`. Besides, it's a plain old HTTP, not a new protocol.
21+
Если нам нужно получать поток данных с сервера: неважно, сообщения в чате или же цены для магазина - вот в чем хорош `EventSource`. К тому же, он поддерживает автоматическое переподключение, которое, используя `WebSocket`, нам бы пришлось поддерживать самим. Кроме того, мы используем старый добрый HTTP, а не новый протокол.
2222

2323
## Getting messages
2424

0 commit comments

Comments
 (0)