CREATE YOUR WORLD
Multiplay

Multiplay Room

5min

Room Connection Process

Document image


👍 Room Connection Process

  1. Request connection from client
  2. ZEPETO Multiplay server generates the Client Session and connects to Room
  3. If Room is successfully connected
    • share the Room ID and Session ID connected to the client
  4. If the client cannot access the Room
    • generate a new Room and connect



Server API

The server code should be implemented in World.multiplay package → index.ts file.

Document image




Server provides the following Room Lifecycle events:

Room Lifecycle Event

Description

onCreate(options: SandboxOptions)

Called once room has been created. Room initialize logic can be added here.

onJoin(client: SandboxPlayer)

Called when the client joined the room. The parameter client (SandboxPlayer) contains the client's sessionId identifier.

onLeave(client: SandboxPlayer, consented?: boolean)

Called when the client left the room. The parameter consented is true when the disconnect is requested by the client.

onTick(deltaTime: number)

Step interval event call on server side, the interval time can be set in SandboxOptions. (tickInterval : 100ms)

  • The OnLeave() event occurs when you press 'Home button > Leave' in the upper left corner during mobile test status.
    • The OnLeave() event does not occur in the Unity editor.



If you're interested in the ZEPETO.Multiplay Server API, refer to the documentation:

📘 Please refer to the following guide. [ZEPETO.Multiplay(Server) API]



Client API

ZepetoWorldMultiplay component provides an interface for clients to subscribe to the World play session (Room) events from ZEPETO Multiplay server.

Document image


List of available events:

Room EventListener

Description

RoomCreated(Room)

Called when a Room is created and accessible. Provides a Room parameter.

RoomJoined(Room)

Called when a Room is connected. Provides a Room parameter.

RoomLeave(RoomLeaveEvent)

Called when disconnecting from a Room. Provides a RoomLeaveEvent parameter.

RoomReconnected(Room)

Called when the corresponding Room is reconnected. Provides a Room parameter.

RoomError(RoomErrorEvent)

Called when an error occurs in the corresponding Room. Provides a RoomErrorEvent parameter.

RoomWeakConnection

Called when the connection is unstable.