How to make a Random Match?

0 votes

Hello ShepHertz Staff

I have three type of multiplayer game which are "Easy,Medium,Hard". When a user authonticated 3 button appears representing 3 type of game. When a user click one of them, he/she will make a quick match with someone who also clicked same type of game. Now, when button clicked, should I create a room or join the room? or What is the code required?

public void RoomTypeEasyBtnClick()

{

    //Code required here?

}

if function calls the api "joinRoomWithProperties" who will create the room?

related to an answer for: Get Started Question
asked Dec 13, 2015 in AppWarp by gokhan (20 points)
edited Dec 13, 2015 by gokhan
In one question, it is said that use "joinRoomInRange" api. But, I wonder than who creates the room? Room is created automatically at background by appwarp itself? I am trying to understand...

1 Answer

0 votes
Hello Gokhan,

 

In order to answer your query, room is not going to add automatically. You need to call create room API and the logic which you need to write is very simple. At the time of clicking button on Easy, Medium and Hard, you need to call joinRoomWithProperties and if the room is not there you will get the exception in callback. In the exception, you can create your room with property of easy, medium and hard mode. This will create your room as a dynamic room.

 

P.S You can also create static room direclty from dashboard as well.

 

Let me know if you need any help while integrating it.

Regards,

HImanshu Sharma
answered Dec 14, 2015 by hs00105 (2,005 points)
Hi Himanshu
Are there any example which demonstrates this usecase? I am a bit confused because are there any possibility that two user clicked same button than no available room, so create two seperate room. But two users are there and can start game...
It happens so fast on the server that there is very less possibility for the same to happen. However, it is possible that 2 users created separate room and waiting for other players to come. But it is a very rare case and it will not come if users are more than 2. Because the 3rd user will definitely get a room to join.
As of now, there is no sample for this specific use-case, how ever we can guide to make one. It is just two API call in sequence.
You first need to call joinRoomWithProperties. In the callback, if you get success response then proceed to your game play otherwise call createRoomWithProperties. In the callback onCreateRoomDone, you need to join the room you just created.

Let me know if you face any problem.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...