Package com.smartfoxserver.util
Class DefaultPlayerIdGenerator
java.lang.Object
com.smartfoxserver.util.DefaultPlayerIdGenerator
- All Implemented Interfaces:
IPlayerIdGenerator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfreePlayerSlot(int playerId) This method is called by the parent Room when a Player leaves the game and his player slot can be freed up.Get a reference to the parent RoomintReturn a new player slot/idvoidinit()The init() method is invoked immediately after the successful creation of the Game Room.voidThis method is invoked upon a Room size change.voidsetParentRoom(Room room)
-
Constructor Details
-
DefaultPlayerIdGenerator
public DefaultPlayerIdGenerator()
-
-
Method Details
-
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:
-
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
Description copied from interface:IPlayerIdGeneratorGet a reference to the parent Room- Specified by:
getParentRoomin interfaceIPlayerIdGenerator- Returns:
- the parent Room
-
setParentRoom
- Specified by:
setParentRoomin interfaceIPlayerIdGenerator
-