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 voidfreePlayerSlot(int playerId)This method is called by the parent Room when a Player leaves the game and his player slot can be freed up.RoomgetParentRoom()Get a reference to the parent RoomintgetPlayerSlot()Return a new player slot/idvoidinit()The init() method is invoked immediately after the successful creation of the Game Room.voidonRoomResize()This method is invoked upon a Room size change.voidsetParentRoom(Room room)
-
-
-
Method Detail
-
init
public void init()
Description copied from interface:IPlayerIdGeneratorThe 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:
initin interfaceIPlayerIdGenerator- See Also:
IPlayerIdGenerator.getParentRoom()
-
getPlayerSlot
public int getPlayerSlot()
Description copied from interface:IPlayerIdGeneratorReturn a new player slot/id- Specified by:
getPlayerSlotin interfaceIPlayerIdGenerator- Returns:
- the new player id
-
freePlayerSlot
public void freePlayerSlot(int playerId)
Description copied from interface:IPlayerIdGeneratorThis method is called by the parent Room when a Player leaves the game and his player slot can be freed up.- Specified by:
freePlayerSlotin interfaceIPlayerIdGenerator- Parameters:
playerId- the id that should be freed up
-
onRoomResize
public void onRoomResize()
Description copied from interface:IPlayerIdGeneratorThis 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:
onRoomResizein interfaceIPlayerIdGenerator
-
getParentRoom
public Room getParentRoom()
Description copied from interface:IPlayerIdGeneratorGet a reference to the parent Room- Specified by:
getParentRoomin interfaceIPlayerIdGenerator- Returns:
- the parent Room
-
setParentRoom
public void setParentRoom(Room room)
- Specified by:
setParentRoomin interfaceIPlayerIdGenerator
-
-