From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/api/websocket/index.html | 248 +++++++++++++++++++++++ files/ko/web/api/websocket/readystate/index.html | 71 +++++++ files/ko/web/api/websocket/websocket/index.html | 51 +++++ 3 files changed, 370 insertions(+) create mode 100644 files/ko/web/api/websocket/index.html create mode 100644 files/ko/web/api/websocket/readystate/index.html create mode 100644 files/ko/web/api/websocket/websocket/index.html (limited to 'files/ko/web/api/websocket') diff --git a/files/ko/web/api/websocket/index.html b/files/ko/web/api/websocket/index.html new file mode 100644 index 0000000000..59bbb8aac9 --- /dev/null +++ b/files/ko/web/api/websocket/index.html @@ -0,0 +1,248 @@ +--- +title: WebSocket +slug: Web/API/WebSocket +tags: + - API +translation_of: Web/API/WebSocket +--- +
{{APIRef("Web Sockets API")}}{{SeeCompatTable}}
+ +

WebSocket 객체는 서버와의 WebSocket 연결을 생성하고 관리할 수 있는 API 들을 제공합니다. 이는 데이터를 전송하거나 주고 받는 등의 API 들을 포함합니다.

+ +

WebSocket 생성자는 하나의 필수 파라미터와, 하나의 옵셔널 파라미터를 받습니다:

+ +
WebSocket WebSocket(
+  in DOMString url,
+  in optional DOMString protocols
+);
+
+WebSocket WebSocket(
+  in DOMString url,
+  in optional DOMString[] protocols
+);
+
+ +
+
url
+
연결할 URL 주소입니다; 웹소켓 서버가 응답할 수 있는 위치의 주소이여야 합니다.
+
protocols {{optional_inline}}
+
단일 프로토콜 문자열, 또는 프로토콜 문자열의 배열. 이 문자열들은 서브 프로토콜을 지정하는데 사용됩니다. 이를 통해 하나의 웹소켓 서버가 여러개의 웹 소켓 서브 프로토콜을 구현할 수 있도록 해줍니다. (예를 들어, 하나의 서버가 두 개 이상의 커뮤니케이션 방식을 가지고 싶도록 하고 싶을 때). 만약 지정하지 않으면 빈 문자열을 넣은 것으로 간주됩니다.
+
+ +

이 생성자는 예외가 발생할 수 있습니다:

+ +
+
SECURITY_ERR
+
The port to which the connection is being attempted is being blocked.
+
+ +

메소드 오버뷰

+ + + + + + + + + + +
void close(in optional unsigned long code, in optional DOMString reason);
void send(in DOMString data);
+ +

어트리뷰트

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeDescription
binaryType{{DOMXref("DOMString")}}A string indicating the type of binary data being transmitted by the connection. This should be either "blob" if DOM {{domxref("Blob")}} objects are being used or "arraybuffer" if {{jsxref("ArrayBuffer")}} objects are being used.
bufferedAmountunsigned longThe number of bytes of data that have been queued using calls to {{manch("send")}} but not yet transmitted to the network. This value does not reset to zero when the connection is closed; if you keep calling {{manch("send")}}, this will continue to climb. Read only
extensions{{DOMXref("DOMString")}}The extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection.
onclose{{domxref("EventListener")}}WebSocket 인터페이스의 연결상태가 readyState 에서CLOSED 로 바뀌었을 때 호출되는 이벤트 리스너입니다. 이 이벤트 리스너는 "close"라는 이름의 CloseEvent를 받습니다.
onerror{{domxref("EventListener")}}"error" 라는 이름의 이벤트가 발생하면 처리할 핸들러입니다. 이는 에러가 발생하는 상황에 호출됩니다.
onmessage{{domxref("EventListener")}}"message" 이름의 MessageEvent 이벤트가 발생하면 처리할 핸들러입니다. 이는 서버로부터 메세지가 도착했을 때 호출됩니다.
onopen{{domxref("EventListener")}}WebSocket 인터페이스의 연결상태가 readyState 에서 OPEN으로 바뀌었을 때 호출되는 이벤트 리스너입니다. ; 연결 상태가 OPEN으로 바뀌었다는 말은 데이터를 주고 받을 준비가 되었다는 뜻입니다. 이 리스너가 처리하는 이벤트는 "open"이라는 이벤트 하나입니다.
protocol{{DOMXref("DOMString")}}서버에 의해 선택된 서브 프로토콜을 가리킵니다; 이 값은 객체를 생성하면서 protocols 파라미터에 전달했던 값 들 중 하나입니다.
readyStateunsigned short연결의 현재 상태입니다; 값은 {{anch("Ready state constants")}} 중에 하나입니다. 읽기 전용.
url{{DOMXref("DOMString")}}생성자에 의해 해석된 URL입니다. 이는 항상 절대 주소를 가리킵니다. 읽기 전용.
+ +

상수

+ +

Ready state constants

+ +

아래의 값들은 readyState 어트리뷰트가 웹소켓의 연결 상태를 나타내기 위해서 사용됩니다.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConstantValueDescription
CONNECTING0연결이 수립되지 않은 상태입니다.
OPEN1연결이 수립되어 데이터가 오고갈 수 있는 상태입니다.
CLOSING2연결이 닫히는 중 입니다.
CLOSED3연결이 종료되었거나, 연결에 실패한 경우입니다.
+ +

메소드

+ +

close()

+ +

맺어진 연결, 또는 연결 시도를 종료합니다. 이미 종료된 경우에는 아무 동작도 하지 않습니다.

+ +
void close(
+  in optional unsigned short code,
+  in optional DOMString reason
+);
+
+ +

Parameters

+ +
+
code {{optional_inline}}
+
연결이 종료되는 이유를 가리키는 숫자 값입니다. 지정되지 않을 경우 기본값은 1000으로 간주됩니다. (일반적인 경우의 "transaction complete" 종료를 나타내는 값).  허용되는 값들은 CloseEvent 페이지의  list of status codes 를 참고하세요.
+
reason {{optional_inline}}
+
연결이 왜 종료되는지를 사람이 읽을 수 있도록 나타내는 문자열입니다. 이 문자열은 UTF-8 포멧이며, 123 바이트를 넘을 수 없습니다. (글자 수 아님).
+
+ +

Exceptions thrown

+ +
+
INVALID_ACCESS_ERR
+
잘못된 code 값을 지정했습니다.
+
SYNTAX_ERR
+
reason 값이 너무 길거나, 짝을 이루지 못하는 서로게이트 문자가 있습니다.
+
+ +
+

Note: In Gecko, this method didn't support any parameters prior to Gecko 8.0 {{geckoRelease("8.0")}}.

+
+ +

send()

+ +

웹소켓 연결을 통해 데이터를 서버로 전송합니다.

+ +
void send(
+  in DOMString data
+);
+
+void send(
+  in ArrayBuffer data
+);
+
+void send(
+  in Blob data
+);
+
+ +

Parameters

+ +
+
data
+
서버로 전송할 텍스트 메세지입니다.
+
+ +

Exceptions thrown

+ +
+
INVALID_STATE_ERR
+
연결이 현재 OPEN 상태가 아닙니다.
+
SYNTAX_ERR
+
data 값에 짝을 이루지 못하는 서로게이트 문자가 있습니다.
+
+ +
+

Note: Gecko's implementation of the send() method differs somewhat from the specification in {{Gecko("6.0")}}; Gecko returns a boolean indicating whether or not the connection is still open (and, by extension, that the data was successfully queued or transmitted); this is corrected in {{Gecko("8.0")}}.

+ +

As of {{Gecko("11.0")}}, support for {{jsxref("ArrayBuffer")}} is implemented but not {{domxref("Blob")}} data types.

+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Websockets", "#the-websocket-interface", "WebSocket")}}{{Spec2("Websockets")}}Initial definition
+ +

브라우저 호환성

+ +
{{Compat("api.WebSocket")}}
+ +

같이 보기

+ + diff --git a/files/ko/web/api/websocket/readystate/index.html b/files/ko/web/api/websocket/readystate/index.html new file mode 100644 index 0000000000..c11bd76867 --- /dev/null +++ b/files/ko/web/api/websocket/readystate/index.html @@ -0,0 +1,71 @@ +--- +title: WebSocket.readyState +slug: Web/API/WebSocket/readyState +translation_of: Web/API/WebSocket/readyState +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.readyState 읽기 전용 속성은 {{domxref("WebSocket")}} 연결의 현재 상태를 반환한다.

+ +

Syntax

+ +
var readyState = aWebSocket.readyState;
+ +

Value

+ +

아래의 unsigned short 값들 중 하나 :

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ValueStateDescription
0CONNECTING소켓이 생성되었다. 연결이 아직 열려 있지 않다.
1OPEN연결이 열려 있고, 통신할 준비가 되었다.
2CLOSING연결이 닫히는 중이다.
3CLOSED연결이 닫혔거나 열 수 없었다.
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-websocket-readystate', 'WebSocket: readyState')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.WebSocket.readyState")}}

diff --git a/files/ko/web/api/websocket/websocket/index.html b/files/ko/web/api/websocket/websocket/index.html new file mode 100644 index 0000000000..93951cf658 --- /dev/null +++ b/files/ko/web/api/websocket/websocket/index.html @@ -0,0 +1,51 @@ +--- +title: WebSocket() +slug: Web/API/WebSocket/WebSocket +translation_of: Web/API/WebSocket/WebSocket +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket() 생성자는 새로운 {{domxref("WebSocket")}} 객체를 반환한다.

+ +

Syntax

+ +
var ws = new WebSocket("ws://localhost:8080");
+ +

Parameters

+ +
+
url
+
연결할 곳의 URL; 웹소켓 서버가 응답할 수 있는 URL 값을 지정해줘야 한다.
+
protocols {{optional_inline}}
+
단일 혹은 여러개의 프로토콜 배열. 이 문자열들은 서브 프로토콜들을 가리킨다. 따라서 하나의 서버는 여러개의 서브 프로토콜을 구현할 수 있다. (예를 들면, 한 개의 서버에서 protocol에 따라 다양한 상호 작용 방식을 사용하기를 바랄 수 있다) . 만약 프로토콜을 지정해주지 않으면, 비어 있다고 간주한다.
+
+ +

Exceptions thrown

+ +
+
SECURITY_ERR
+
연결을 시도하는 포트가 닫혀 있을 때 발생한다.
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-websocket', 'the WebSocket constructor')}}{{Spec2('HTML WHATWG')}} 
+ +

Browser compatibility

+ + + +

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

-- cgit v1.2.3-54-g00ecf