ZEPETO.Multiplay
20 min
type description sandboxplayer /#sandboxplayer represents a player's client connected to the multiplay room ibroadcastoptions /#ibroadcastoptions options for broadcasting messages from the multiplay room to clients sandboxoptions /#sandboxoptions options for creating a multiplay room sandbox /#sandbox represents a multiplay room sandboxplayer interface represents a player's client connected to the multiplay room properties name type description sessionid string client's session id userid string player's user id methods send send(type string | number, message? t) → void sends a message through a specified channel to a client parameter type description type string | number the identifier of the channel to send the message through message (optional) t message optional content of the message to be sent ibroadcastoptions interface options for broadcasting messages from the multiplay room to clients properties name type description except sandboxplayer /#sandboxplayer specifies a client to be excluded from the broadcast sandboxoptions interface options for creating a multiplay room properties name type description issandbox boolean specifies whether the room is hosted locally, such as for qr mobile testing in the unity editor sandbox class represents a multiplay room properties name type description locked boolean specifies whether the multiplay room is locked roomid string id of the multiplay room, assigned randomly upon creation to avoid duplication uniqueid string id of the multiplay room, explicitly assigned upon creation maxclients number maximum number of clients able to connect to the multiplay room state state state of a multiplay room the schema for the state data is defined by the multiplay schema clients iterableiterator\<sandboxplayer> iterable representation of the clients connected to the multiplay room allowreconnectiontime number time limit (in seconds) for allowing the reconnection of a client with an unstable connection private boolean specifies whether the multiplay room is private methods oncreate oncreate(options sandboxoptions) → void | promise\<void> implementation of this abstract method is run once, when the multiplay room is created implementation can be optionally declared async parameter type description options sandboxoptions /#sandboxoptions options for creating the multiplay room returns void | promise\<void> — if asynchronous, it returns promise\<void> otherwise, void onjoin onjoin(client sandboxplayer) → void | promise\<void> implementation of this abstract method is run when a client joins the multiplay room implementation can be optionally declared async parameter type description client sandboxplayer /#sandboxplayer client object of the player returns void | promise\<void> — if asynchronous, it returns promise\<void> otherwise, void onleave onleave(client sandboxplayer, consented? boolean) → void | promise\<void> implementation of this abstract method is run when a client leaves the multiplay room implementation can be optionally declared async parameter type description client sandboxplayer /#sandboxplayer client object of the player consented (optional) boolean specifies whether the player has consented to reconnect returns void | promise\<void> — if asynchronous, it returns promise\<void> otherwise, void lock lock() → promise\<void> locks the multiplay room returns promise\<void> — promise resolved upon completion of the locking process unlock unlock() → promise\<void> unlocks the multiplay room returns promise\<void> — promise resolved upon completion of the unlocking process ontick ontick(deltatime number) → void implementation of this method is executed approximately every 100 milliseconds parameter type description deltatime number represents the time difference (in milliseconds) from the previous call onmessage onmessage(messagetype ' ' | string | number, callback (client sandboxplayer, message t) => void) → void registers a callback to handle messages received from clients parameter type description messagetype ' ' | string | number the identifier of the channel the message was sent through callback (client sandboxplayer, message t) => void callback method to handle the received message broadcast broadcast(type string | number, message? any, options? ibroadcastoptions) → void sends a message through a specified channel to every client connected to the multiplay room parameter type description type string | number the identifier of the channel to send the message through message (optional) any optional content of the message options (optional) ibroadcastoptions /#ibroadcastoptions broadcast options loadplayer loadplayer(sessionid string) → sandboxplayer | undefined gets the client object associated with a session id parameter type description sessionid string client's session id returns sandboxplayer | undefined — the client object setprivate setprivate(isprivate boolean) → promise\<void> sets the private status of the multiplay room parameter type description isprivate boolean specifies the private status of the multiplay room returns promise\<void> — promise resolved upon completion of the process kick kick(client sandboxplayer, reason? string) → promise\<void> kicks out a client from the multiplay room parameter type description client sandboxplayer /#sandboxplayer object of the client to be kicked out reason (optional) string optionally describe the reason for the kick out returns promise\<void> — promise resolved upon completion of the process
