Page 1 of 1

dynamic rooms not working

Posted: 23 Jun 2010, 11:46
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");

Posted: 23 Jun 2010, 12:21
by Bax
Did you check both the client and the server logs? You will probably see errors reported.

Posted: 23 Jun 2010, 15:08
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'

Posted: 24 Jun 2010, 07:19
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.

Posted: 24 Jun 2010, 08:53
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.

Re: dynamic rooms not working

Posted: 19 Oct 2011, 10:35
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