From 95aca4b4d8fa62815d4bd412fff1a364f842814a Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 29 Apr 2021 16:16:42 -0700 Subject: remove retired locales (#699) --- files/vi/web/api/eventsource/index.html | 127 ---------------------------- files/vi/web/api/eventsource/url/index.html | 59 ------------- 2 files changed, 186 deletions(-) delete mode 100644 files/vi/web/api/eventsource/index.html delete mode 100644 files/vi/web/api/eventsource/url/index.html (limited to 'files/vi/web/api/eventsource') diff --git a/files/vi/web/api/eventsource/index.html b/files/vi/web/api/eventsource/index.html deleted file mode 100644 index 36a35382dd..0000000000 --- a/files/vi/web/api/eventsource/index.html +++ /dev/null @@ -1,127 +0,0 @@ ---- -title: EventSource -slug: Web/API/EventSource -tags: - - API - - Communications - - EventSource - - Interface - - NeedsTranslation - - Reference - - Server Sent Events - - Server-sent events - - TopicStub - - messaging -translation_of: Web/API/EventSource ---- -
{{APIRef("Server Sent Events")}}
- -

The EventSource interface is web content's interface to server-sent events. An EventSource instance opens a persistent connection to an HTTP server, which sends events in text/event-stream format. The connection remains open until closed by calling {{domxref("EventSource.close()")}}.

- -

Once the connection is opened, incoming messages from the server are delivered to your code in the form of {{event("message")}} events.

- -

Unlike WebSockets, server-sent events are unidirectional; that is, data messages are delivered in one direction, from the server to the client (such as a user's web browser). That makes them an excellent choice when there's no need to send data from the client to the server in message form. For example, EventSource is a useful approach for handling things like social media status updates, news feeds, or delivering data into a client-side storage mechanism like IndexedDB or web storage.

- -

Constructor

- -
-
{{domxref("EventSource.EventSource", "EventSource()")}}
-
Creates a new EventSource to handle receiving server-sent events from a specified URL, optionally in credentials mode.
-
- -

Properties

- -

This interface also inherits properties from its parent, {{domxref("EventTarget")}}.

- -
-
{{domxref("EventSource.readyState")}} {{readonlyinline}}
-
A number representing the state of the connection. Possible values are CONNECTING (0), OPEN (1), or CLOSED (2).
-
{{domxref("EventSource.url")}} {{readonlyinline}}
-
A {{domxref("DOMString")}} representing the URL of the source.
-
{{domxref("EventSource.withCredentials")}} {{readonlyinline}}
-
A {{domxref("Boolean")}} indicating whether the EventSource object was instantiated with cross-origin (CORS) credentials set (true), or not (false, the default).
-
- -

Event handlers

- -
-
{{domxref("EventSource.onerror")}}
-
Is an {{domxref("EventHandler")}} called when an error occurs and the {{domxref("EventSource/error_event", "error")}} event is dispatched on an EventSource object.
-
{{domxref("EventSource.onmessage")}}
-
Is an {{domxref("EventHandler")}} called when a {{domxref("EventSource/message_event", "message")}} event is received, that is when a message is coming from the source.
-
{{domxref("EventSource.onopen")}}
-
Is an {{domxref("EventHandler")}} called when an {{domxref("EventSource/open_event", "open")}} event is received, that is when the connection was just opened.
-
- -

Methods

- -

This interface also inherits methods from its parent, {{domxref("EventTarget")}}.

- -
-
{{domxref("EventSource.close()")}}
-
Closes the connection, if any, and sets the readyState attribute to CLOSED. If the connection is already closed, the method does nothing.
-
- -

Events

- -
-
{{domxref("EventSource/error_event", "error")}}
-
Fired when a connection to an event source failed to open.
-
{{domxref("EventSource/message_event", "message")}}
-
Fired when data is received from an event source.
-
{{domxref("EventSource/open_event", "open")}}
-
Fired when a connection to an event source has opened.
-
- -

Examples

- -

In this basic example, an EventSource is created to receive events from the server; a page with the name sse.php is responsible for generating the events.

- -
var evtSource = new EventSource('sse.php');
-var eventList = document.querySelector('ul');
-
-evtSource.onmessage = function(e) {
-  var newElement = document.createElement("li");
-
-  newElement.textContent = "message: " + e.data;
-  eventList.appendChild(newElement);
-}
- -

Each received event causes our EventSource object's onmessage event handler to be run. It, in turn, creates a new {{HTMLElement("li")}} element and writes the message's data into it, then appends the new element to the list element already in the document.

- -
-

Note: You can find a full example on GitHub — see Simple SSE demo using PHP.

-
- -

Specifications

- - - - - - - - - - - - -
SpecificationStatus
{{SpecName('HTML WHATWG', "comms.html#the-eventsource-interface", "EventSource")}}{{Spec2('HTML WHATWG')}}
- - - -

Browser compatibility

- -
- - -

{{Compat("api.EventSource")}}

-
- -

See also

- - diff --git a/files/vi/web/api/eventsource/url/index.html b/files/vi/web/api/eventsource/url/index.html deleted file mode 100644 index 2af6554db0..0000000000 --- a/files/vi/web/api/eventsource/url/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: EventSource.url -slug: Web/API/EventSource/url -translation_of: Web/API/EventSource/url ---- -
{{APIRef('WebSockets API')}}
- -

url là thuộc tính chỉ đọc của giao diện {{domxref("EventSource")}} trả về {{domxref("DOMString")}} đại diện cho URL của nguồn.

- -

Cú pháp

- -
var myUrl = eventSource.url;
- -

Giá trị

- -

{{domxref("DOMString")}} đại diện cho URL của nguồn.

- -

Ví dụ

- -
var evtSource = new EventSource('sse.php');
-console.log(evtSource.url);
- -
-

Ghi chú: bạn có thể xem ví dụ đầy đủ trên GitHub — xem Simple SSE demo using PHP.

-
- -

Thông số kĩ thuật

- - - - - - - - - - - - - - -
Thông số kĩ thuậtTrạng tháiChú thích
{{SpecName('HTML WHATWG', "comms.html#dom-eventsource-url", "url")}}{{Spec2('HTML WHATWG')}}Định nghĩa ban đầu
- - - -

Trình duyệt tương thích

- -
- - -

{{Compat("api.EventSource.url")}}

-
- -

Liên quan

- - -- cgit v1.2.3-54-g00ecf