Package com.smartfoxserver.v2.util
Class DefaultPlayerIdGenerator
- java.lang.Object
-
- com.smartfoxserver.v2.util.DefaultPlayerIdGenerator
-
- All Implemented Interfaces:
IPlayerIdGenerator
public class DefaultPlayerIdGenerator extends java.lang.Object implements IPlayerIdGenerator
-
-
Constructor Summary
Constructors Constructor Description DefaultPlayerIdGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
freePlayerSlot(int playerId)
This method is called by the parent Room when a Player leaves the game and his player slot can be freed up.Room
getParentRoom()
Get a reference to the parent Roomint
getPlayerSlot()
Return a new player slot/idvoid
init()
The init() method is invoked immediately after the successful creation of the Game Room.void
onRoomResize()
This method is invoked upon a Room size change.void
setParentRoom(Room room)
-
-
-
Method Detail
-
init
public void init()
Description copied from interface:IPlayerIdGenerator
The init() method is invoked immediately after the successful creation of the Game Room. Here the developer can add any initialization code. It is recommended to use this method instead of the constructor to setup your data structures etc... This is because only in the init() method you will be able to access the parent Room.- Specified by:
init
in interfaceIPlayerIdGenerator
- See Also:
IPlayerIdGenerator.getParentRoom()
-
getPlayerSlot
public int getPlayerSlot()
Description copied from interface:IPlayerIdGenerator
Return a new player slot/id- Specified by:
getPlayerSlot
in interfaceIPlayerIdGenerator
- Returns:
- the new player id
-
freePlayerSlot
public void freePlayerSlot(int playerId)
Description copied from interface:IPlayerIdGenerator
This method is called by the parent Room when a Player leaves the game and his player slot can be freed up.- Specified by:
freePlayerSlot
in interfaceIPlayerIdGenerator
- Parameters:
playerId
- the id that should be freed up
-
onRoomResize
public void onRoomResize()
Description copied from interface:IPlayerIdGenerator
This method is invoked upon a Room size change. Depending on the logic that generates Player id(s) it might be necessary to take rearrange player id data after a Room resize.- Specified by:
onRoomResize
in interfaceIPlayerIdGenerator
-
getParentRoom
public Room getParentRoom()
Description copied from interface:IPlayerIdGenerator
Get a reference to the parent Room- Specified by:
getParentRoom
in interfaceIPlayerIdGenerator
- Returns:
- the parent Room
-
setParentRoom
public void setParentRoom(Room room)
- Specified by:
setParentRoom
in interfaceIPlayerIdGenerator
-
-