Join A Random Room Or Create A New Room If No Room Is Available

If you simply want to have your client join or create a room randomly, use this method.

The event raised by the method is the same: OnJoin/OnMemberJoin or OnCreate.

If a UDP client is used, the message is sent as an RUDP.

int maxMembers = 10; // Maximum number of members for this room
int ttl = 60; // TTL of the room in seconds when it is empty (this is only effective when allowEmpty=true)

// This message will be sent to the other members when you join the room successfully. Other members will receive the message via OnMemberJoin event
byte[] message = Encoding.UTF8.GetBytes(messageData);

// Broadcast message buffering interval in milliseconds to lessen server stress
int interval = 200;

room.JoinRandom(maxMembers, ttl, message, interval);

Last updated