> 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 comms 프로토콜이 지원하는 섬 메시징 전송 방식 중 하나입니다. 클라이언트는 자신의 realm의 [Archipelago](https://github.com/decentraland/docs/tree/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`]\[Packet]과 혼동해서는 안 됩니다. 이는 웹소켓 전송에 특화된 추가 래핑 계층입니다. 실제 comms 메시지는 [`WsPeerUpdate`](#WsPeerUpdate) 유형에 포함됩니다.
{% endhint %}

| 필드    | 타입    | 값                                                                                                                                                                                                                                                 |
| ----- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `메시지` | `열거형` | <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를 realm의 [Archipelago](https://github.com/decentraland/docs/tree/main/contributor/archipelago/README.md) 이전 인증 라운드 이후에 획득한 경우에도.

클라이언트가 섬에 참여할 때 처음 보내는 메시지는 [`WsIdentification`](https://github.com/decentraland/protocol/blob/c48ea0aa00d8173084571552463a6a05a7f49636/proto/decentraland/kernel/comms/rfc5/ws_comms.proto#L64)이며, 여기에는 공개 주소가 포함됩니다. 이에 대해 [`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/tree/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` | 연결이 종료되는 이유에 대한 서버의 설명 |

### 클라이언트 메시지

comms를 전송하려면 [메시지](https://github.com/decentraland/docs/tree/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                                                                                     |
| `전신`         | `bytes`  | 직렬화된 [메시지](https://github.com/decentraland/docs/tree/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
