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)

messageData.SenderID = id;
messageData.Message = "Hello";
byte[] message = encoder.Encode(messageData); // This message will be sent to the other members when you join the room successfully. Other members will receive the message via OnMemberJoin event
int interval = 200; // Broadcast message buffering interval in milliseconds to lessen server stress
room.JoinRandom(maxMembers, ttl, message, interval);