Unable To Create Dynamic Room Android

0 votes

I want to create a mulitiplayer quiz app where 2 players play inside a room. The room should be created on Player1s request to create a room.

I tried using 'join room api' initially so that the call back will notify there is no rooms available and on the call back, i called 'Create Room API'. Also I added ZoneRequestListner and got a sucessful callback on 'OnConnectDone'. But i am unable to create a room where the opponent can join. How can i create such a dynamic room.

 

Please provide any sample code for creating such dynamic rooms.

Thanks

asked Jan 2, 2017 in Work In Progress by jishnukanthpt (21 points)
edited Jan 2, 2017 by jishnukanthpt

1 Answer

0 votes
 
Best answer

Hi Jishnu,

Greetings from ShepHertz!!!

Here are the steps you can follow to achieve the goals.

  1. Connect With AppWarp using Coonect API and you will be getting callback in onCoonectDone.
  2. Once you will be successfully connected with AppWarp, use JoinRoom API to join a room if already created.
  3. Either you will get a success result in onJoinRoomDone callback of RoomListener or if not get succes you can call createRoom API here for creating Dynamic room on server as there is no room. you will be getting callback in onCreateRoomDone in ZoneListener.
  4. Once Room is created you need to join the room with roomID you will be getting in onCreateRoomDobe method.
  5. Once players able to join the rooms you can start your game play based on your logic.

Let me know if more queries are concern.

Thanks

Vishnu Garg

answered Jan 2, 2017 by Vishnu Garg (674 points)
selected Jan 3, 2017 by jishnukanthpt
Thankz Vishnu, that really helped!!

i do have a few queries too.

Do you provide any APIs to find random people playing the game so that a Player can find anyone available to play a 'Vs' game with him.

Is there any matchmaking APIs likewise or should i have to implement my own logic here??
While creation a Room you can define Room properties. and while joining a room player can join a room with some specific properties.
You can use joinRoomWithPropperties API for the same.
If there is room exist with the property you have passed you will be getting success response else you can create a room with the properties you want.

Workflow will be same as I have explained above.
where will i get the response of 'joinRoomWithProperties'??
I created a room and tried joining a room like this:

warpClient.joinRoom("1349501272");

but i am not getting any response.
CallBack is same onJoinRoomDone
not entering into onJoinRoomDone!
Please share the steps that you follow for the same. Also try the same in debug mode by applying the breakpoint in onJoinRoomDone method
on join button click, i used:

  warpClient.joinRoom("1349501272");

and onJoinRoomDone is:

 @Override
    public void onJoinRoomDone(RoomEvent roomEvent) {
        Log.e("join ","done "+roomEvent.getResult());
        
        Toast.makeText(MainActivity.this,"ROOM >"+roomEvent.getData().getId(),Toast.LENGTH_SHORT).show();
    }

i placed breakpoint inside 'onJoinRoomDone' but there is no hit triggered  inside it.
i created the room with one phone and fetched the roomId("1349501272"). Then i used the same id to join the room with another phone.
Yes, You can join the same room on another device. Before calling this have you get success response in onConnectDone method.
Yes I got success response in onConnectDone. But 'onJoinRoomDone' is not getting triggered when i use:

 warpClient.joinRoom("1349501272");
Have you added RoomListener on the object you want callback.
I used the listeners - ConnectionRequestListener,RoomRequestListener,ZoneRequestListener

initialised  like -
 WarpClient.initialize(API_KEY,SECRET_KEY);
        try {
           warpClient =  WarpClient.getInstance();
            warpClient.addConnectionRequestListener(this);
            warpClient.addZoneRequestListener(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        warpClient.connectWithUserName("User");

created room like -
 createBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                warpClient.createRoom("RoomTest123","User",2,null);
            }
        });

joined  like -
 joinBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                             warpClient.joinRoom("1753248396");
             

            }
        });

 @Override
    public void onJoinRoomDone(RoomEvent roomEvent) {
        Log.e("join ","done "+roomEvent.getResult());
        roomEvent.getResult();

        Toast.makeText(MainActivity.this,"ROOM >"+roomEvent.getData().getId(),Toast.LENGTH_SHORT).show();
    }


Nothing  happened :(
Figured out the issue.

I forgot to add  warpClient.addRoomRequestListener(this);

thankz
Thanks and let me know if more queries are there.
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
...