Class DefaultPlayerIdGenerator

java.lang.Object
com.smartfoxserver.util.DefaultPlayerIdGenerator
All Implemented Interfaces:
IPlayerIdGenerator

public class DefaultPlayerIdGenerator extends Object implements IPlayerIdGenerator
  • Constructor Details

    • DefaultPlayerIdGenerator

      public DefaultPlayerIdGenerator()
  • Method Details

    • 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 interface IPlayerIdGenerator
      See Also:
    • getPlayerSlot

      public int getPlayerSlot()
      Description copied from interface: IPlayerIdGenerator
      Return a new player slot/id
      Specified by:
      getPlayerSlot in interface IPlayerIdGenerator
      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 interface IPlayerIdGenerator
      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 interface IPlayerIdGenerator
    • getParentRoom

      public Room getParentRoom()
      Description copied from interface: IPlayerIdGenerator
      Get a reference to the parent Room
      Specified by:
      getParentRoom in interface IPlayerIdGenerator
      Returns:
      the parent Room
    • setParentRoom

      public void setParentRoom(Room room)
      Specified by:
      setParentRoom in interface IPlayerIdGenerator