Im using Android. I have two Android devices. The first is creating a room. The second tries to
join that room by invoking "joinRoomInRange". But surprise surprise: It doesnt work somehow.
I checked if theres any room available by invoking "getAllRooms". I saw that the count of rooms is zero.
In the function "onJoinRoomDone" the event code will always be 2, so it will always create a new room.
I would really appreciate your help!
Heres some code:
The Client class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | public class Client
{
public static WarpClient myGame;
public static String userID = "0" ;
public static Runnable runConnection = new Runnable() {
@Override
public void run() {
myGame.connectWithUserName(userID);
}
};
public static void connect()
{
WarpClient.initialize( "c5be1255ff52056714e535960879f55f5e90c2950faf1f52b6f15c7a531fb56e" , "25dc5c77b767efe7ac29ac847824c72d041ed3f1f6c662050210281a3b69de17" );
try {
myGame = WarpClient.getInstance();
myGame.addConnectionRequestListener( new MyConnectionListener());
myGame.addChatRequestListener( new MyChatListener());
myGame.addZoneRequestListener( new MyZoneListener());
myGame.addRoomRequestListener( new MyRoomRequestListener());
myGame.addNotificationListener( new MyNotificationListener());
createUserID();
new Thread(runConnection).start();
}
catch (Exception e)
{
e.printStackTrace();
}
}
....
|
Function of ConnectionRequestListener class that implements ConnectionRequestListener:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @Override
public void onConnectDone(ConnectEvent event) {
if (event.getResult() == WarpResponseResultCode.SUCCESS){
System.out.println( "yipee I have connected" );
Client.myGame.getAllRooms();
Client.myGame.joinRoomInRange( 1 , 1 , false );
}
}
....
|
Function of RoomRequestListener class that implements RoomRequestListener:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | @Override
public void onJoinRoomDone(RoomEvent event) {
if (event.getResult() == WarpResponseResultCode.SUCCESS) {
roomId = event.getData().getId();
Client.myGame.subscribeRoom(roomId);
} else if (event.getResult() == WarpResponseResultCode.RESOURCE_NOT_FOUND) {
HashMap<String, Object> data = new HashMap<String, Object>();
data.put( "result" , "" );
Client.myGame.createRoom( "superjumper" , "shephertz" , 2 ,data);
} else {
Client.myGame.disconnect();
}
}
...
|