Skip to content

Commit 591d782

Browse files
Merge pull request #1164 from javascript-tutorial/cbnu-elec-2021-summer
[웹소켓] 충북대 특강 실습용
2 parents 51ba2b0 + c91d245 commit 591d782

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

5-network/11-websocket/article.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,25 @@ Sec-WebSocket-Protocol: soap
166166
167167
- 텍스트 프레임(text frame) -- 텍스트 데이터가 담긴 프레임
168168
- 이진 데이터 프레임(binary data frame) -- 이진 데이터가 담긴 프레임
169-
- "ping/pong frames" are used to check the connection, sent from the server, the browser responds to these automatically.
170-
이 외에도 '커넥션 종료 프레임(connection close frame)' 등 다양한 프레임이 있음
169+
- 핑 또는 퐁 프레임(ping/pong frame) -- 커넥션이 유지되고 있는지 확인할 때 사용하는 프레임으로 서버나 브라우저에서 자동 생성해서 보내는 프레임
170+
- 이 외에도 '커넥션 종료 프레임(connection close frame) 등 다양한 프레임이 있음
171171
172172
브라우저 환경에서 개발자는 텍스트나 이진 프레임만 다루게 됩니다.
173173
174-
**WebSocket `.send()` method can send either text or binary data.**
174+
이유는 **WebSocket `.send()` 메서드는 텍스트나 바이너리 데이터만 보낼 수 있기 때문입니다.**
175175
176-
A call `socket.send(body)` allows `body` in string or a binary format, including `Blob`, `ArrayBuffer`, etc. No settings required: just send it out in any format.
176+
`socket.send(body)`를 호출할 때, `body`엔 문자열이나 `Blob`, `ArrayBuffer`등의 이진 데이터만 들어갈 수 있습니다. 데이터 종류에 따라 특별히 무언가 세팅을 해줘야 할 필요는 없고, 텍스트나 바이너리 타입의 데이터를 넣어주면 알아서 데이터가 전송됩니다.
177177
178-
**When we receive the data, text always comes as string. And for binary data, we can choose between `Blob` and `ArrayBuffer` formats.**
178+
한편, **데이터를 받을 때, 텍스트 데이터는 항상 문자열 형태로 옵니다. 이진 데이터를 받을 때엔 `Blob`이나 `ArrayBuffer` 포맷 둘 중 하나를 고를 수 있습니다.**
179179
180180
`socket.binaryType` 프로퍼티를 사용하면 `Blob`이나 `ArrayBuffer` 포맷 둘 중 하나를 고를 수 있는데, 프로퍼티 기본값은 `"blob"`이라서 이진 데이터는 기본적으로 `Blob` 객체 형태로 전송받게 됩니다.
181181
182-
[Blob](info:blob) is a high-level binary object, it directly integrates with `<a>`, `<img>` and other tags, so that's a sane default. But for binary processing, to access individual data bytes, we can change it to `"arraybuffer"`:
182+
[Blob](info:blob)은 고차원(high-level)의 이진 객체인데, `<a>` `<img>` 등의 태그와 바로 통합할 수 있어서 기본값으로 아주 적절합니다. 하지만 이진 데이터를 처리하는 과정에 개별 데이터 바이트에 접근해야 하는 경우엔 프로퍼티 값을 `"arraybuffer"`로 바꿀 수도 있습니다.
183183
184184
```js
185185
socket.binaryType = "arraybuffer";
186186
socket.onmessage = (event) => {
187-
// event.data is either a string (if text) or arraybuffer (if binary)
187+
// event.data는 (텍스트인 경우) 문자열이거나 (이진 데이터인 경우) arraybuffer 입니다.
188188
};
189189
```
190190

0 commit comments

Comments
 (0)