dynamic rooms not working

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Post Reply
pmarreddy
Posts: 16
Joined: 07 Jun 2010, 09:21

dynamic rooms not working

Post by pmarreddy »

I was trying to create dynamic rooms through a server side extension, when i send the avatar to the room the avatar is stuck , i mean he is not moving.

Code: Select all

String tempfile = data.getString("home");
		
		String templName = tempfile = "123#"+tempfile;
		String mapName = templName + requester.getName();
		
		// Create a new map file, and check if it already exists
		File newMap = new File("openSpace/data/" + mapName + ".map"); 
		
		if(!newMap.exists()) 
		{
			// If the map doesn't exist already, duplicate the template
			File templMap = new File("openSpace/data/" + templName + ".map"); 
			
			InputStream in = new FileInputStream(templMap);
		    OutputStream out = new FileOutputStream(newMap);
		
		    // Copy data from template file to new file
		    byte[] buf = new byte[1024];
		    int len;
		
		    while ((len = in.read(buf)) > 0) {
		        out.write(buf, 0, len);
		    }
		
		    in.close();
		    out.close();
		}
		
		// Set the properties of a dynamic SmartFoxServer Room corresponding to the map.
		Map<String, String> params = new HashMap<String, String>(); 
		params.put("name", templName+ requester.getName());
		params.put("maxU", "10");
		params.put("pwd", "testpwd"); // We add a password so other users can't enter the requester's home.
		
		// Assign the map to the Room by means of the _os_mapId Room Variable.
		HashMap<String, RoomVariable> roomVars = new HashMap<String, RoomVariable>();
		RoomVariable mapRoomVar = new RoomVariable(templName + requester.getName(), "s", null, true, false); 
		roomVars.put("_os_mapId", mapRoomVar);
		
		// Create the dynamic SmartFoxServer Room corresponding to the map.
		Room newRoom = null; 
		try { 
			newRoom = ExtensionHelper.instance().createRoom(ExtensionHelper.instance().getZone(this.getOwnerZone()), params, requester, roomVars, null, false, true, true);
		} catch (ExtensionHelperException e)
		{
			e.printStackTrace();
		}
		
		// If Room creation was successful, send the user to his own home.
		if(newRoom != null) 
			super.sendAvatarToMap(requester, newRoom.getId(), "testpwd");
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Did you check both the client and the server logs? You will probably see errors reported.
Paolo Bax
The SmartFoxServer Team
pmarreddy
Posts: 16
Joined: 07 Jun 2010, 09:21

Post by pmarreddy »

I am getting this error in log file

2010/06/23 21:03:27.515 - [ SEVERE ] [id: 30] (Logger.logError): [OpenSpace] An exception occurred while executing command _os_path
2010/06/23 21:03:27.703 - [ INFO ] [id: 30] (Logger.logInfo): [OpenSpace] User xz [11] requested path from (1, 9, 0) to (12, 12, 0) on map '123#gatexz'
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Quite difficult to help you. The error you get is very generic and there's no stack trace... strange! Can you please send us by email the full server side log when doing the whole flow?
- start the server
- run the client
- create the new map
- make the avatar move

Please keep your actions to the minimum required to make the error happen, so that the log is not excessively long. Also please send the map and the assets required to render it on the client.
Paolo Bax
The SmartFoxServer Team
pmarreddy
Posts: 16
Joined: 07 Jun 2010, 09:21

Post by pmarreddy »

Thanks for your help, i have solved it. Actually the problem is the client is not getting roomsupdated event so i sent a rooms update event from the server and then i sent the avatar to the room from the client, it worked.
Hannek
Posts: 1
Joined: 19 Oct 2011, 10:32

Re: dynamic rooms not working

Post by Hannek »

pmarreddy wrote:I was trying to create dynamic rooms through a server side extension
View also www.smartfoxserver.com/docs/index.htm?http://www.smartfoxserver.com/docs/docPages/sfsPro/roomArchitecture.htm
Post Reply