Hi,
I am a new in Java. Please feel to read my English
Using Flex side I am creating a room with Extension with Room Variables like bellow
// Flex Code bellow
var settings:SFSGameSettings = new SFSGameSettings("gameRoom1");
settings.maxUsers = 2;
settings.maxSpectators = 10;
settings.isPublic = true;
settings.minPlayersToStartGame = 2;
settings.notifyGameStarted = true;
settings.leaveLastJoinedRoom = false;
settings.extension = new RoomExtension("sfsGame", "sfs2x.extensions.games.pingPong.SFSPingPong");
// Create some Room Variables
var roomVars:Array = [];
roomVars.push(new SFSRoomVariable("gameStarted", false));
roomVars.push(new SFSRoomVariable("gameType", "Ping"));
roomVars.push(new SFSRoomVariable("minRank", 10));
roomVars.push(new SFSRoomVariable("type", "fun"));
roomVars.push(new SFSRoomVariable("desc", " game, public, bestScore > 100"));
settings.variables = roomVars;
sfs.send(new CreateSFSGameRequest(settings));
Room is created but the problem is another player is entered Room variables not getting,
By using Server side Java we can set property Global so every one can get Room variables.
Can you please help to me how to write java Server side Code to set Global.
Advance Thanks
Krishsalt
SFS2X how to set Global Room Variables
Hi. So here's an example of a way you can do it:
ArrayList<SFSRoomVariable> roomVars = new ArrayList<SFSRoomVariable>();
//the second true you can change to false, as it sets if the variable is persistent or not:
roomVars.add(new SFSRoomVariable("myVar", myValue, false, true, true))
//sender: the user that sent the extension request. If the extension sets the variables without an user sending a request, then you can set it to null
//room: the room where the variable is being set.
//You can get the room, for example, by using:
//Room room = SmartFoxServer.getInstance().getZoneManager().getZoneByName("myZoneName").getRoomByName("myRoomName");
getApi().setRoomVariables(sender, room, roomVars);
ArrayList<SFSRoomVariable> roomVars = new ArrayList<SFSRoomVariable>();
//the second true you can change to false, as it sets if the variable is persistent or not:
roomVars.add(new SFSRoomVariable("myVar", myValue, false, true, true))
//sender: the user that sent the extension request. If the extension sets the variables without an user sending a request, then you can set it to null
//room: the room where the variable is being set.
//You can get the room, for example, by using:
//Room room = SmartFoxServer.getInstance().getZoneManager().getZoneByName("myZoneName").getRoomByName("myRoomName");
getApi().setRoomVariables(sender, room, roomVars);
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
-
- Posts: 108
- Joined: 06 Jan 2010, 09:50
- Location: chennai
- Contact:
Re: SFS2X how to set Global Room Variables
Hi,
I create a room in java server side after receive a request from client AS3, Room created successfully but at the time of room creation i set some room variables that is not received after room created in client side, Below i added my code
CreateRoomSettings settings = new CreateRoomSettings();
settings.setName(roomName);//---Used to create a room Name---
settings.setMaxUsers(5);
settings.setMaxVariablesAllowed(20);
settings.setExtension(new RoomExtensionSettings ("SkyTeenpatti_logic","vali.logic.TeenPattiLogic"));
settings.setAutoRemoveMode(SFSRoomRemoveMode.WHEN_EMPTY);
settings.setDynamic(true);
ArrayList <RoomVariable> rs = new ArrayList<RoomVariable>();
rs.add(new SFSRoomVariable("isGameRunning",false));
settings.setRoomVariables(rs);
try
{
getApi().createRoom(zone, settings, null);
}
catch (SFSCreateRoomException e)
{
trace("Room Create Exception Received");
}
I create a room in java server side after receive a request from client AS3, Room created successfully but at the time of room creation i set some room variables that is not received after room created in client side, Below i added my code
CreateRoomSettings settings = new CreateRoomSettings();
settings.setName(roomName);//---Used to create a room Name---
settings.setMaxUsers(5);
settings.setMaxVariablesAllowed(20);
settings.setExtension(new RoomExtensionSettings ("SkyTeenpatti_logic","vali.logic.TeenPattiLogic"));
settings.setAutoRemoveMode(SFSRoomRemoveMode.WHEN_EMPTY);
settings.setDynamic(true);
ArrayList <RoomVariable> rs = new ArrayList<RoomVariable>();
rs.add(new SFSRoomVariable("isGameRunning",false));
settings.setRoomVariables(rs);
try
{
getApi().createRoom(zone, settings, null);
}
catch (SFSCreateRoomException e)
{
trace("Room Create Exception Received");
}
Sankar.G
Re: SFS2X how to set Global Room Variables
Hi,
the server code is right so I don't see why you shouldn't receive the variables on client side.
Keep in mind that variables are seen only from users joined in the Room. If you want variables to be available even to users not joined you will need to set them as global.
In other words:
Hope it helps
the server code is right so I don't see why you shouldn't receive the variables on client side.
Keep in mind that variables are seen only from users joined in the Room. If you want variables to be available even to users not joined you will need to set them as global.
In other words:
Code: Select all
RoomVariable myVar = new SFSRoomVariable("myVar", "myValue");
myVar.setGlobal(true);
Hope it helps
Return to “SFS2X ActionScript 3 API”
Who is online
Users browsing this forum: No registered users and 20 guests