CREATE YOUR WORLD
멀티플레이
Multiplay 일시적인 Room 접속 제한하기
4분
원하는 시점에 방 접근을 제한하거나 허용하기 위해 잠금 및 잠금 해제 기능을 사용할 수 있습니다.
📘 다음 가이드를 참조하십시오. [ZEPETO.Multiplay(Server) API]
잠금 기능은 방 접근을 제한하는 기능입니다.
TypeScript
1await this.lock();
잠금 해제 기능은 방 접근을 허용하는 기능입니다. 하지만 현재 연결된 사람 수가 방에 허용된 최대 인원 수와 같으면 방을 잠금 해제할 수 없습니다.
TypeScript
1await this.unlock();
다음은 잠금 및 잠금 해제 기능을 사용하는 예제 코드입니다.
TypeScript
1import { Sandbox, SandboxOptions, SandboxPlayer } from 'ZEPETO.Multiplay';
2
3export default class extends Sandbox {
4
5 onCreate(options: SandboxOptions) {
6
7 }
8
9 async onJoin(client: SandboxPlayer) {
10 try {
11 if (this.clients.length > 8) {
12 await this.lock();
13 }
14 } catch(e) {
15 console.error(e);
16 }
17 }
18
19 async onLeave(client: SandboxPlayer, consented?: boolean){
20 try {
21 if (this.clients.length <= 8) {
22 await this.unlock();
23 }
24 } catch(e) {
25 console.error(e);
26 }
27 }
28}
업데이트됨 11 Oct 2024

이 페이지가 도움이 되었습니까?