Class MessageManager

All Implemented Interfaces:
Disposable, Manager

public final class MessageManager extends Manager.ManagerWithListeners<MessageManager.MessageManagerListener>
  • Constructor Details

    • MessageManager

      public MessageManager()
  • Method Details

    • setup

      public void setup()
      Description copied from interface: Manager
      Called when all manager objects are already created and can be accessed
      Specified by:
      setup in interface Manager
      Overrides:
      setup in class Manager.ManagerWithListeners<MessageManager.MessageManagerListener>
    • processLocalMessages

      public void processLocalMessages()
    • getMessages

      public Array<MessageManager.Message> getMessages()
      Returns:
      sorted (by date) list of messages that has not been deleted yet
    • isMessageRead

      public boolean isMessageRead(String id)
      Parameters:
      id - id of the message
      Returns:
      true if message has been read by the player
    • markMessageRead

      public void markMessageRead(MessageManager.Message message)
      Mark a message as read. Notifies the server and listeners.
      Parameters:
      message - message to mark as read
    • isMessageEverDeleted

      public boolean isMessageEverDeleted(String id)
      Parameters:
      id - id of the message
      Returns:
      true if message has been manually deleted by the player. Can return false if message not exists and has not been deleted - to check if message exists, use getMessage() and check for null
    • isMessageItemsReceived

      public boolean isMessageItemsReceived(String id)
    • deleteMessage

      public void deleteMessage(MessageManager.Message message)
      Delete the message and remember its id in the list of deleted messages. Notifies the server. If message is notDeletable, does nothing and prints an error.
      Parameters:
      message - message to delete
    • requestMessagesFromServer

      public void requestMessagesFromServer()
    • removeMessage

      public void removeMessage(MessageManager.Message message)
      Remove message and do not store its id in the list of deleted messages. Notifies listeners. Does not notify the server.
    • addMessage

      public void addMessage(MessageManager.Message message)
      Add a message and notify listeners. If message with the same id already exists, it will be replaced
      Parameters:
      message - message to add
    • getMessage

      @Null public MessageManager.Message getMessage(String id)
      Get a message with the id specified
      Parameters:
      id - id of the message
      Returns:
      Message or null if message not exists
    • getUnreadMessageCount

      public int getUnreadMessageCount()
    • getTotalMessageCount

      public int getTotalMessageCount()
    • receiveMessageItems

      public void receiveMessageItems(MessageManager.Message message)
    • isRequestingServer

      public boolean isRequestingServer()