> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-ko/communications/transport-types/websocket.md).

# 웹소켓

웹소켓 전송은 Decentraland 통신 프로토콜이 지원하는 아일랜드 메시징 전송 방식 중 하나입니다. 클라이언트는 자신의 realm의 적절한 연결 문자열을 받으면 이를 사용해야 합니다 [Archipelago](https://github.com/decentraland/docs/blob/main/contributor/archipelago/README.md) 서비스에서 적절한 연결 문자열을 받거나, 고정 전송 방식으로 표시된 경우 이를 사용해야 합니다.

웹소켓 전송의 맥락에서, 아일랜드는 다음과 같이 불립니다 *방*. 어느 이름이든 같은 것을 의미합니다: 업데이트와 채팅을 주고받는 가까운 플레이어들의 그룹.

연결 문자열은 다음으로 시작합니다 `ws-room:` 접두사, 그 뒤에 오는 `wss://` 특정 방의 URI입니다. 형식은 다음과 같습니다:

```
ws-room:wss://comms.example.com/rooms/<room-id>
```

웹소켓 URI에 명시적인 프로토콜이 없는 경우, `wss://` 가정됩니다.

### 연결

전송은 HTTPS 위에서 일반적인 웹소켓 프로토콜을 사용합니다. 클라이언트는 자신이 사용할 수 있는 어떤 표준 구현이든 사용해 연결을 열 수 있습니다.

### 웹소켓 패킷

웹소켓 전송의 모든 메시지는 다음을 사용해 직렬화됩니다 [`WsPacket`](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L78) 구조체를 사용합니다. 이는 프로토콜 수준의 연결 및 인증 메시지 집합과, 클라이언트 메시지를 위한 컨테이너 타입을 구현합니다.

{% hint style="info" %}
이 [`WsPacket`](#WsPacket) 구조체는 메시지 \[`패킷`]\[Packet]와 혼동해서는 안 됩니다. 이는 웹소켓 전송에 특화된 추가 래핑 계층입니다. 실제 통신 메시지는 다음 안에 포함됩니다 [`WsPeerUpdate`](#WsPeerUpdate) 타입.
{% endhint %}

| 필드        | 유형    | 값                                                                                                                                                                                                                                                    |
| --------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message` | `열거형` | <p>다음 중 하나입니다 <code>WsIdentification</code>, <code>WsChallengeRequired</code>, <code>WsSignedChallenge</code>,<br><code>WsWelcome</code>, <code>WsPeerJoin</code>, <code>WsPeerLeave</code>, <code>WsKicked</code> 또는 <code>WsPeerUpdate</code>.</p> |

### 인증

클라이언트가 다른 이들에게 메시지 릴레이를 시작하기 전에, 챌린지 문자열에 서명하여 인증해야 합니다. 이는 전송 URI를 다음에서 얻었더라도 필요합니다 [Archipelago](https://github.com/decentraland/docs/blob/main/contributor/archipelago/README.md) 이전 인증 과정을 거친 후에도.

클라이언트가 아일랜드에 참여할 때 보내는 첫 번째 메시지는 [`WsIdentification`](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L64)공개 주소를 포함하는 WsIdentification입니다. 이에 대한 응답으로 [`WsChallengeRequired`](#WsChallengeRequired)가 전송되며, 클라이언트는 답장으로 [`WsSignedChallenge`](#WsSignedChallenge) 를 보냅니다.

```
  .----------.                .--------.
  |  서버  |                | 클라이언트 |
  '----+-----'                '---+----'
       ⋮                          |
       ⋮                  연결 |
       o - - - - - - - - - - - - -|
       |                          |
       |                          |
       |         WsIdentification |
       |<-------------------------+
       +------------------------->|
       | WsChallengeRequired      |
       |                          |
       |                          |
       |        WsSignedChallenge |
       |<-------------------------+
       +------------------------->|
       | WsWelcome                |
       |                          |

```

흐름이 성공적으로 완료되면, 클라이언트는 [`WsWelcome`](#WsWelcome) 를 받게 되며 피어에게 메시지를 보내기 시작할 수 있습니다.

***

**`WsIdentification`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L64)

| 필드        | 유형       | 값                     |
| --------- | -------- | --------------------- |
| `address` | `string` | 클라이언트의 공개 Ethereum 주소 |

***

**`WsChallengeRequired`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L48)

| 필드                  | 유형       | 값                               |
| ------------------- | -------- | ------------------------------- |
| `challenge_to_sign` | `string` | 신원 증명으로 서명해야 하는 서버 제공 문자열       |
| `already_connected` | `string` | 기존 연결이 닫힐 수 있음을 나타내는 서버의 힌트입니다. |

***

**`WsSignedChallenge`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L56)

| 필드                | 유형       | 값                                                                                                    |
| ----------------- | -------- | ---------------------------------------------------------------------------------------------------- |
| `auth_chain_json` | `string` | 직렬화된 [인증 체인](https://github.com/decentraland/docs/blob/main/auth/authchain/README.md) 챌린지 서명으로 끝납니다. |

***

**`WsWelcome`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L11)

| 필드                | 유형                    | 값                     |
| ----------------- | --------------------- | --------------------- |
| `별칭`              | `uint32`              | 클라이언트 세션에 대한 서버 생성 ID |
| `peer_identities` | `map<uint32, string>` | 별칭으로 색인된 현재 모든 피어의 주소 |

### 연결

클라이언트가 자신의 피어와 자신의 상태를 추적하는 데 도움이 되도록 세 가지 메시지가 정의되어 있습니다.

[`WsPeerJoin`](#WsPeerJoin) 는 다른 클라이언트가 방에 연결하여 인증에 성공했을 때 수신되며, 반면 [`WsPeerLeave`](#WsPeerLeave) 는 피어가 연결을 끊을 때 수신됩니다.

또한 다음 메시지도 있습니다 [`WsKicked`](#WsKicked) 메시지는 클라이언트의 연결이 곧 종료될 것임과 그 이유를 알려줍니다. 현재 실무에서 서버가 클라이언트를 방에서 내보낼 수 있는 주된 이유는, 서버 정책상 금지되어 있음에도 동시에 다른 방에 연결했기 때문입니다.

***

**`WsPeerJoin`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L19)

| 필드        | 유형       | 값                                           |
| --------- | -------- | ------------------------------------------- |
| `별칭`      | `uint32` | 다음에 전송되는 서버 생성 ID [`WsWelcome`](#WsWelcome) |
| `address` | `string` | 새 피어의 Ethereum 주소                           |

***

**`WsPeerLeave`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L27)

| 필드   | 유형       | 값                   |
| ---- | -------- | ------------------- |
| `별칭` | `uint32` | 연결이 끊긴 피어의 서버 생성 ID |

***

**`WsKicked`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L74)

| 필드       | 유형       | 값                      |
| -------- | -------- | ---------------------- |
| `reason` | `string` | 연결이 종료되는 이유에 대한 서버의 설명 |

### 클라이언트 메시지

통신을 보내려면 [메시지](https://github.com/decentraland/docs/blob/main/contributor/messages/README.md)클라이언트는 이를 다음 안에 감쌉니다 [`WsPeerUpdate`](#WsPeerUpdate) 구조체를 사용합니다. 이렇게 하면 전송 제어 메시지 유형과 피어 간에 전송되는 실제 메시지가 구분됩니다.

```
.-------------------.
| WsPacket          |
|  .--------------. |
|  | WsPeerUpdate | |
|  | .----------. | |
|  | |  Packet  | | |
|  | '----------' | |
|  '--------------' |
'-------------------'

```

***

**`WsPeerUpdate`** [**↗ 소스**](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L34)

| 필드           | 유형       | 값                                                                                                  |
| ------------ | -------- | -------------------------------------------------------------------------------------------------- |
| `from_alias` | `uint32` | 보낸 쪽의 서버 생성 ID                                                                                     |
| `body`       | `bytes`  | 직렬화된 [message](https://github.com/decentraland/docs/blob/main/contributor/messages/README.md) 감싸지는 |
| `비신뢰성`       | `bool`   | 보낸 사람이 이 메시지를 전달할 때 속도와 신뢰성 중 무엇을 우선시했는지                                                           |

클라이언트는 다음 값을 설정해야 합니다 `from_alias` 필드를 다음으로 `0` 전송할 때, 그러면 서버가 이를 피어에게 전달하기 전에 올바른 식별자로 채웁니다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/contributor/contributor-ko/communications/transport-types/websocket.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
