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 in Work In Progress by jishnukanthpt (21 points)
edited Jan 2 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 by Vishnu Garg (663 points)
selected Jan 3 by jishnukanthpt
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
Migrate from Parse to ShepHertz App42
...