> 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/creator/content-creator-ko/sdk7/networking/third-party-servers.md).

# 서드파티 서버

서드파티 서버를 사용해 멀티플레이어 Decentraland 씬을 구축합니다.

씬에서 멀티플레이어 상호작용을 구현할 때 권장되는 방식은 [멀티플레이어 서버](https://docs.decentraland.org/creator/content-creator-ko/sdk7/networking/authoritative-servers.md)를 사용하는 것입니다. 이 문서에서는 지원되는 다른 옵션도 다룹니다.

* **REST API + DB**: 자주 바뀌지 않는 데이터(리더보드, 방명록)에 적합합니다. 플레이어는 업데이트를 확인하기 위해 API를 주기적으로 호출하며, 상태는 세션 간에도 유지됩니다. 씬에서 [네트워크 연결](https://docs.decentraland.org/creator/content-creator-ko/sdk7/networking/network-connections.md) 을 통해 `fetch` 요청을 보내는 방법을 알아보세요.
* **WebSocket 서버**: 실시간 양방향 통신을 지원합니다. WebSocket 사용 방법은 [네트워크 연결](https://docs.decentraland.org/creator/content-creator-ko/sdk7/networking/network-connections.md) 을 참고하세요. [Colyseus](https://colyseus.io/) 와 같은 라이브러리는 Decentraland SDK와 잘 호환됩니다.

{% hint style="warning" %}
**📔 참고**: 서드파티 서버는 `syncEntity`, `validateBeforeChange`또는 `Storage` 와 통합되지 않으므로 상태 관리와 동기화 로직을 직접 구현해야 합니다.
{% endhint %}

플레이어 간 변경 사항은 [serverless-multiplayer](https://docs.decentraland.org/creator/content-creator-ko/sdk7/networking/serverless-multiplayer.md)를 통해 알리고, 최종 상태는 나중에 방문하는 사용자를 위해 REST API에 저장하는 하이브리드 방식도 사용할 수 있습니다.

다음은 서드파티 서버를 사용하는 씬의 예입니다.

* [리더보드](https://github.com/decentraland/sdk7-goerli-plaza/tree/main/leader-board)
* [방명록](https://github.com/decentraland/sdk7-goerli-plaza/tree/main/guest-book-api)
* [진위 검증](https://github.com/decentraland/sdk7-goerli-plaza/tree/main/validate-player-authenticity)

## 로컬에서 테스트하기

서드파티 서버를 사용하는 씬을 미리 보려면 씬과 씬이 의존하는 서버를 모두 실행해야 합니다. 테스트하기 쉽도록 미리보기와 같은 컴퓨터에서 서버를 로컬로 실행할 수 있습니다. 로컬에서 실행할 때는 설정을 간편하게 하기 위해 안전하지 않은 `http` 또는 `ws` 연결을 사용할 수 있습니다.

서버를 시작하려면 `/server` 폴더로 이동해 다음을 실행하세요. `npm run start`.

미리보기를 별도의 창 두 개에서 엽니다. 각 창은 서로 다른 플레이어로 취급됩니다. 각 창을 서로 다른 주소에 연결하세요. 두 클라이언트 모두 같은 로컬 서버 인스턴스에 연결됩니다.

Creator Hub에서 **다중 인스턴스 미리 보기** 을 **데스크톱 클라이언트** 의 하위 메뉴 **재생 옵션**, 그런 다음 **재생**  버튼을 한 번 더 클릭하면 Decentraland 탐색기 창이 하나 더 열립니다. 두 창 모두 서로 다른 주소로 연결해야 합니다. 장면이 다시 로드되어도 두 세션은 열린 상태로 유지됩니다.

또는 브라우저 주소창에 다음을 입력해 Decentraland 탐색기 창을 하나 더 열 수 있습니다.

> `decentraland://realm=http://127.0.0.1:8000&local-scene=true&debug=true&multi-instance=true`

## 별도의 렐름

Decentraland의 플레이어는 여러 개의 별도 *렐름*에 존재합니다. 서로 다른 렐름의 플레이어는 같은 구획에 서 있더라도 서로를 볼 수 없고, 상호작용하거나 채팅할 수 없습니다. 이렇게 플레이어를 나누면 제한에 부딪히지 않고 Decentraland에서 무제한의 플레이어를 처리할 수 있습니다. 또한 가까운 지역에 있는 플레이어를 같은 렐름에 배정해, 상호작용하는 플레이어 간의 핑 시간이 적절하게 유지되도록 합니다.

씬에서 서드파티 서버로 데이터를 보내 플레이어 간 변경 사항을 실시간으로 동기화한다면, 같은 렐름에 있는 플레이어끼리만 변경 사항이 동기화되도록 해야 합니다. 한 렐름에 속한 모든 변경 사항은 다른 렐름의 변경 사항과 분리해 처리해야 합니다. 그렇지 않으면 누구도 변경하지 않았는데 사물이 갑자기 바뀌는 것처럼 보여 플레이어가 혼란스러워할 수 있습니다.

각 플레이어의 렐름을 가져오는 방법은 [플레이어 데이터 가져오기](https://docs.decentraland.org/creator/content-creator-ko/sdk7/interactivity/user-data.md)

## 멀티플레이어 지속성

플레이어가 들어올 때마다 새로 마운트되는 로컬 씬과 달리, 서드파티 서버를 사용하는 씬은 플레이어가 씬에 들어오고 나간 뒤에도 계속 유지됩니다.

따라서 플레이어가 언제나 같은 초기 상태의 씬을 보게 되지는 않는다는 점을 고려해 경험을 설계해야 합니다. 씬에 적용된 변경 사항은 이후 방문하는 플레이어에게도 계속 남으므로, 이러한 변경이 미래 플레이어의 경험에 의도치 않은 영향을 주지 않도록 해야 합니다.

### 상태 초기화

씬을 불러올 때 기본 상태가 아니라 서버에 저장된 공유 정보를 바탕으로 구성되도록 하세요.

경우에 따라 씬에 일종의 초기화 버튼을 넣는 것이 좋습니다. 이 버튼을 누르면 씬을 안전하게 초기화할 수 있습니다.

때로는 씬 상태의 변수를 기본값으로 되돌리는 것만으로 충분합니다. 하지만 씬을 초기화할 때 서버 측의 리스너 구독을 해제하고 루프를 중지해야 할 수도 있습니다. 씬을 초기화할 때마다 빈 루프가 남으면 계속 쌓여 씬의 성능에 악영향을 미칠 수 있습니다.


---

# 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/creator/content-creator-ko/sdk7/networking/third-party-servers.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.
