how to judge the room is disposed ?

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
jenth
Posts: 14
Joined: 25 Aug 2009, 07:04

how to judge the room is disposed ?

Post 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 !
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
jenth
Posts: 14
Joined: 25 Aug 2009, 07:04

Post by jenth »

i will do it. thank you for your help.
jenth
Posts: 14
Joined: 25 Aug 2009, 07:04

Post 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;
    }
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Are you sure there is no server side error and the room is actually created?
Lapo
--
gotoAndPlay()
...addicted to flash games
jenth
Posts: 14
Joined: 25 Aug 2009, 07:04

Post 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());
			}
jenth
Posts: 14
Joined: 25 Aug 2009, 07:04

Post by jenth »

Thanks for your time.
Post Reply