---
title: Multiplay 일시적인 Room 접속 제한하기
slug: world-sdk-guide-kr/iCoK-multiplay-room
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

원하는 시점에 방 접근을 제한하거나 허용하기 위해 잠금 및 잠금 해제 기능을 사용할 수 있습니다.

:::hint{type="info"}
**📘&#x20;**&#xB2E4;음 가이드를 참조하십시오. \[[ZEPETO.Multiplay(Server) API](https://developer.zepeto.me/docs/multiplay-server/classes/ZEPETO_Multiplay.Sandbox#lock)]
:::

## 잠금

잠금 기능은 방 접근을 제한하는 기능입니다.

```typescript
await this.lock();
```



## 잠금 해제

잠금 해제 기능은 방 접근을 허용하는 기능입니다.
하지만 현재 연결된 사람 수가 방에 허용된 최대 인원 수와 같으면 방을 잠금 해제할 수 없습니다.

```typescript
await this.unlock();
```



## 예제

다음은 잠금 및 잠금 해제 기능을 사용하는 예제 코드입니다.

```typescript
import { Sandbox, SandboxOptions, SandboxPlayer } from 'ZEPETO.Multiplay';

export default class extends Sandbox {

    onCreate(options: SandboxOptions) {

    }

    async onJoin(client: SandboxPlayer) {
        try {
            if (this.clients.length > 8) {
                await this.lock();
            }
        } catch(e) {
            console.error(e);
        }
    }

    async onLeave(client: SandboxPlayer, consented?: boolean){
        try {
            if (this.clients.length <= 8) {
                await this.unlock();
            }
        } catch(e) {
            console.error(e);
        }
    }
}
```

:::hint{type="success"}
## 👍 잠금과 개인 기능의 차이

- 잠금된 멀티플레이어 방은 ZEPETO 방 목록에 표시되지 않으며 초대 없이 들어갈 수 없습니다.
- 개인 멀티플레이어 방은 ZEPETO 방 목록에 표시되지 않지만 초대는 가능합니다.
:::

