Hi,
I use my extension to create room on server side by using the SFSApi#createRoom method.
The docs said that game rooms are removed when empty,but it is still there.
Thank you.
Game room is not removed when empty
-
- Posts: 15
- Joined: 02 Mar 2011, 14:12
Same issue
Hi, I'm also having this issue.
Below is my code for creating games.
Games show up in other clients as having no participants, yet they still exist until a server restart.
Below is my code for creating games.
Games show up in other clients as having no participants, yet they still exist until a server restart.
Code: Select all
package RTS;
import com.smartfoxserver.v2.SmartFoxServer;
import com.smartfoxserver.v2.annotations.Instantiation;
import com.smartfoxserver.v2.annotations.Instantiation.InstantiationMode;
import com.smartfoxserver.v2.api.CreateRoomSettings.RoomExtensionSettings;
import com.smartfoxserver.v2.entities.Room;
import com.smartfoxserver.v2.entities.SFSRoomRemoveMode;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import com.smartfoxserver.v2.exceptions.SFSCreateRoomException;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import com.smartfoxserver.v2.game.CreateSFSGameSettings;
@Instantiation(InstantiationMode.SINGLE_INSTANCE)
public class NewGame extends BaseClientRequestHandler {
public NewGame() {
}
@Override
public void handleClientRequest(User sender, ISFSObject params) {
ServerExtension server = (ServerExtension)(this.getParentExtension());
SmartFoxServer sfs = SmartFoxServer.getInstance();
String gameName = params.getUtfString("game_name");
trace("Creating new game: "+gameName+"\n");
//Create new game room
CreateSFSGameSettings settings = getGameSettings(gameName);
ISFSObject msg = SFSObject.newInstance();
msg.putBool("status", true);
Room game;
try {
//Create Game
game = sfs.getAPIManager().getGameApi().createGame(server.getParentZone(), settings, sender);
msg.putUtfString("game_room", game.getName());
server.addGame(game);
} catch (SFSCreateRoomException e) {
trace("Error: Game could not be created."+e.getMessage());
msg.putBool("status", false);
e.printStackTrace();
}
send("newGameResponse", msg, sender);
}
private CreateSFSGameSettings getGameSettings(String name){
RoomExtensionSettings gameExtensionSettings = new RoomExtensionSettings("RTSServer","RTS.GameExtension");
CreateSFSGameSettings settings = new CreateSFSGameSettings();
settings.setName(name);
settings.setGroupId("games");
settings.setGame(true);
settings.setGamePublic(true);
settings.setMinPlayersToStartGame(1);
settings.setMaxUsers(10);
settings.setMaxSpectators(20);
settings.setMinPlayersToStartGame(1);
settings.setMaxVariablesAllowed(10);
settings.setAutoRemoveMode(SFSRoomRemoveMode.WHEN_EMPTY);
settings.setExtension(gameExtensionSettings);
return settings;
}
}
-
- Posts: 15
- Joined: 02 Mar 2011, 14:12
Oops nvm
Figured it out.
I hadn't done
Its weird that these things don't have sensible defaults (considering this is a game room).
For anyone interested, is a handy way to check everything is set correctly (outputs to server log).
I hadn't done
Code: Select all
settings.setDynamic(true);
Its weird that these things don't have sensible defaults (considering this is a game room).
For anyone interested,
Code: Select all
trace(game.getDump())
Who is online
Users browsing this forum: Google [Bot] and 76 guests