Get result 4(BadRequest) in onJoinRoomDone when invoke joinRoom(String id)

0 votes

Hello everyone,

I'm just new to Appwarp and i'm trying to develop a sample app.

The idea in simple is: 1 user connect to server, create a turn base room, and join that room.

theClient.createTurnRoom("dmm", "khang", 2, null, 1000000);

and

 public void onCreateRoomDone(RoomEvent re) {
        if (re.getResult() == 0) {
            System.out.println("Created 1 room id" + re.getData().getId());
            theClient.joinRoom(re.getData().getId());
        }
        System.out.println("The result of creating:" + re.getResult());
    }

 

1 more user connect to server. Get all rooms and join the first room.

 theClient.getAllRooms();

and:

 public void onGetAllRoomsDone(AllRoomsEvent are) {
        System.out.println("Get all rooms result: " + are.getResult());
        if (are.getResult() == 0 && are.getRoomIds() == null) {
 
            theClient.createTurnRoom("Khang", "ABCDEF", 2, null, 1000000);
 
        } else if (are.getRoomIds() != null) {
            for (int i = 0; i < are.getRoomIds().length; i++) {
                System.out.println(are.getRoomIds()[i]);
            }
            theClient.joinRoom(are.getRoomIds()[0]);
 
            System.out.println("Have room, joining");
        }
    }
 
 
I got stuck at there, where the first user create and join room successfully but the second user, who get all room and join the first room got result = 4 in onJoinRoomDone
 
 public void onJoinRoomDone(RoomEvent re) {
        
        if (re.getResult() == 0) {
            theClient.subscribeRoom(re.getData().getId());
            System.out.println("Joined room" + re.getData().getId());
        } else {
            System.out.println(re.getResult);
        }
 
    }

 

asked May 18, 2015 in AppWarpS2 by khangbkhn (10 points)
edited May 20, 2015 by khangbkhn
Can you also share code snippet for joining a room on other client? Which SDK are you using?
Sorry i've just change the code for testing. The code for joining a room on other client is:

 public void onGetAllRoomsDone(AllRoomsEvent are) {
        System.out.println("Get all rooms result: " + are.getResult());
        if (are.getResult() == 0 && are.getRoomIds() == null) {

            theClient.createTurnRoom("Khang", "ABCDEF", 2, null, 1000000);

        } else if (are.getRoomIds() != null) {
            for (int i = 0; i < are.getRoomIds().length; i++) {
                System.out.println(are.getRoomIds()[i]);
            }
            theClient.joinRoom(are.getRoomIds()[0]);

            System.out.println("Have room, joining");
        }
    }

It's simple : get all rooms. if room exists -> join the first room

I used the SDK for java client.

1 Answer

0 votes
Hi,

BAD_REQUEST occurs in following cases:

1. If the room is full

2. If the room already contains that user.

So please verify that you are somehow not joining the same room or if the room's max limit is correct or if the room is not full. You can use getLiveRoomInfo and getLiveUserInfo APIs to get info about the room and user which will help you to understand what exactly wrong is happening.

Thanks
answered May 20, 2015 by Suyash Mohan (900 points)
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
...