Page 1 of 1

how to judge the room is disposed ?

Posted: 22 Dec 2009, 02:46
by jenth
hi,
in my app, i use java extend a object named Street in server side.
code :

public class Street {
private String streetId;
private HashMap<String, Room> roomMap;
private int maxCount;
.........
}

in server side, when i create a new dynamic room that will disposed if no user in, also add that into roomMap.
code :
createdRoom = helper.createRoom(zone, map, u, true, true);
roomMap.put('test', createdRoom);

The problem is when room disposed by server framework, but in roomMap pointer to createdRoom has value not null.
code:
Room room = roomMap.get('test')
trace( room != null ) // true

how to judge the room is disposed ? has other advice ?

thanks !

Posted: 22 Dec 2009, 08:26
by Lapo
Instead of keeping a reference to the Room, keep a reference to its ID, which will never change until the Room exist. This way you will need to call the Zone.getRoom() method to obtain the Room and it will return null when it will be disposed

Posted: 22 Dec 2009, 14:52
by jenth
i will do it. thank you for your help.

Posted: 23 Dec 2009, 11:28
by jenth
hi,
i have got a new problem.
in server side extent create a new room, but users of the zone not receive the onRoomAdded event .thanks

Code: Select all

private Room createRoom(String roomName, User u){
 
    	HashMap<String, String> map = new HashMap<String, String>();
    	map.put("name", roomName);
        map.put("isGame", "true");
        map.put("isLimbo","false");
        map.put("maxU", "3");
    	Room createdRoom = null;
		try {
			createdRoom = helper.createRoom(zone, map, u, true, true);
		} catch (ExtensionHelperException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			trace("createRoom error:" +roomName+","+e);
		}
		trace("createRoom:"+createdRoom.getName()+" Successfully");
    	return createdRoom;
    }

Posted: 28 Dec 2009, 11:26
by Lapo
Are you sure there is no server side error and the room is actually created?

Posted: 28 Dec 2009, 14:36
by jenth
server side has not error and i'm sure the room is created i got it in AdminTool. mybe the reason is i use joinroom after createroom, i find it if remove joinroom the client side will get onRoomAdded event .thanks

Code: Select all

try {
	helper.joinRoom(u, fromRoom, joinRoom.getId(), true, "", false, true);
	} catch (ExtensionHelperException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		trace("joinRoom error"+e.getMessage());
		trace("joinRoom error getLocalizedMessage"+e.getLocalizedMessage());
			}

Posted: 02 Jan 2010, 09:51
by jenth
Thanks for your time.