> 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/transports.md).

# 전송 방식

A *전송* 클라이언트 측 인터페이스로, comms URI에 연결하여 동료나 서비스와 실시간 메시지를 교환할 수 있습니다.

{% hint style="info" %}
오픈소스 [Comms Station](https://decentraland.github.io/comms-station/).
{% endhint %}

클라이언트는 다른 클라이언트와 서비스가 기대하는 프로토콜을 따르기만 하면, 원하는 방식으로 전송을 구현할 수 있습니다. 하지만 [권장 설계](#recommended) 아래에 설명된 권장 설계는 실제로 테스트되었고 다양한 프로젝트와 잘 통합되는 것으로 입증되었습니다.\`

### 표준 전송 방식 <a href="#types" id="types"></a>

프로토콜은 5가지 전송 유형을 정의합니다:

* [웹소켓](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/websocket/README.md) (`ws-room`)는 표준 웹소켓 스트림을 사용합니다.
* [LiveKit](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/livekit/README.md) (`livekit`)는 WebRTC 기반의 오픈소스 LiveKit 프레임워크를 사용합니다.
* [SignedLogin](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/signed_login/README.md) (`signed-login`)는 서버에서 동적으로 할당된 전송을 가져오기 위해 서명된 HTTPS 요청을 보냅니다.
* [오프라인](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/offline/README.md) (`offline`)는 현재 환경에 통신이 없음을 나타내는 더미 전송입니다.
* [시뮬레이터](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/simulator/README.md) (`simulator`)는 완전히 사용자 정의된 동작을 가진 더미 전송으로, 주로 개발자가 구현을 디버깅할 때 사용합니다.

전송 인터페이스를 통해 송수신되는 메시지는 항상 동일합니다(see [메시지](https://github.com/decentraland/docs/blob/main/contributor/communications/messages/README.md)). 일부 전송은 전송을 위해 제어 구조로 이를 감쌀 수 있지만, 이는 `Transport` 인터페이스를 넘기기 전에 풀어야 합니다.

### 권장 설계 <a href="#recommended" id="recommended"></a>

다음은 최소한의 `Transport` TypeScript로 작성된 인터페이스입니다:

```ts
interface Transport {
  // URI로 Transport를 초기화합니다:
  constructor(private uriWithConnectionParams: string)

  // constructor에서 제공된 URI를 사용하여 연결을 엽니다:
  connect(): Promise<void>

  // 연결을 종료합니다:
  disconnect(): Promise<void>

  // 서비스와 모든 피어에게 임의의 페이로드를 전송합니다:
  send(packet: Packet): Promise<void>

  // 서비스와 모든 피어로부터 들어오는 메시지를 구독합니다:
  on(event: 'receive', callback: (packet: Packet) => void): void
}
```

실제 구현은 일반적으로 이를 확장하여 연결/연결 해제 및 참여/이탈 이벤트, 브로드캐스트하지 않는 전송, 더 엄격한 타이핑 또는 언어별 적응을 추가합니다.

#### 전송 URI

값은 `uriWithConnectionParams` 항상 다음 형식입니다:

```
<type>:<type connection parameters>
```

이 `<type>` 위에 나열된 것 중 하나에 해당하며, `<type connection parameters>` 는 특정 전송 방식에 따라 달라집니다. URL, 불투명한 토큰 또는 임의의 데이터일 수 있습니다.

이 [LiveKit](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/livekit/README.md) 전송은 예를 들어 `wss` URL과 `access_token` 매개변수를 사용하여 인증된 연결을 설정합니다:

```
livekit:wss://comms.example.com?access_token=eyJhbGciOiJI...
```

비교하자면, [웹소켓](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/websocket/README.md) 전송도 `wss` URL을 사용하지만, 미리 생성된 토큰은 사용하지 않습니다. 연결 후에는 인증 흐름이 필요합니다.

#### 전송 생성

각 `Transport` 클래스가 특정 종류의 URI를 지원하므로, 유효한 `Transport` 를 반환하거나 즉시 실패하는 팩토리 메서드를 두는 것이 좋습니다. 예를 들면:

```ts
function createTransport(uriWithConnectionParams: string) {
  const type = getPrefix(urlWithConnectionParams)

  switch (type) {
    case 'ws-room': return new WsRoomTransport(uriWithConnectionParams)
    case 'livekit': return new LiveKitTransport(uriWithConnectionParams)
    // ... 기타 지원되는 구현...
  }

  throw new Error(`지원되지 않는 전송 유형: ${type}`)
}
```

클라이언트는 모든 표준 전송 방식을 구현할 필요는 없습니다. 정의된 유형의 하위 집합만 사용하고 모든 URI를 처리하려는 목적이 아니라면, 지원하지 않는 유형은 거부해도 됩니다.

월드 익스플로러와 같은 더 많은 기능을 갖춘 클라이언트는 최소한 [웹소켓](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/websocket/README.md) 및 [LiveKit](https://github.com/decentraland/docs/blob/main/contributor/communications/transport-types/livekit/README.md) 전송 방식을 구현하는 것이 좋습니다. 이는 현재 모든 주요 영역에서 사용되고 있습니다.

### 더 알아보기

다음으로 이동하세요: [특정 전송 유형](#types) 섹션에서 다양한 [메시지 유형에 대해 읽어보세요](https://github.com/decentraland/docs/blob/main/contributor/communications/messages/README.md) 또는 \[\[Comms Demo Station]]을 확인해 보세요.


---

# 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/transports.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.
