CREATE YOUR WORLD
Multiplay

Multiplay Room Message

9min

Multiplay Room Message

Document image




ZEPETO Multiplay provides an interface for sending/receiving messages between clients and servers (Room). The server can send messages exclusively to individual clients or globally to all connected clients.

The delivery message types supports Primitive, Schema, Custom(Object) types.

Server API

The Server API provides the following Method.

API

Description

onMessage(Type, Callback)

The ZEPETO Multiplay server can register callbacks mapped them by type to handle messages sent by clients. The type parameter can be defined as a string.

client.send(Type, Message)

Function for sending messages to a specific client.

broadcast(Type, Message)

Function for sending messages to all clients connected to the room. You can send it to all connected clients, or you can additionally exclude specific clients from the list.

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

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



Receive a message

The following is an example of using onMessage.

TypeScript




Send Message

The following is an example of using client.send.

TypeScript




The following is an example of using broadcast.



â–¼ Example of broadcasting a message to all clients

TypeScript




â–¼ Example of broadcasting a message with excluding specific clients

TypeScript




Client API

The Client API provides the following Method.

room.AddMessageHandler(Type, Message)

Messages received from the server can be received by registering an AddMessageHandler callback. You can define the message type you want to receive when registering a message callback.

room.Send(Type, message)

Interface used to forward messages to the server. You can define the message type to forward.

Receive a message The following is an example of using room.AddMessageHandler.

TypeScript




Send Message The following is an example of using room.Send.

TypeScript




Check out examples of various types of Room Message.

Server

TypeScript


Client

TypeScript