Class ChatHistoryRequestHandler

java.lang.Object
nl.andrewl.concord_server.event.ChatHistoryRequestHandler
All Implemented Interfaces:
MessageHandler<nl.andrewl.concord_core.msg.types.chat.ChatHistoryRequest>

public class ChatHistoryRequestHandler extends Object implements MessageHandler<nl.andrewl.concord_core.msg.types.chat.ChatHistoryRequest>
Handles client requests for sections of chat history for a particular channel.
  • Constructor Details

    • ChatHistoryRequestHandler

      public ChatHistoryRequestHandler()
  • Method Details

    • handle

      public void handle(nl.andrewl.concord_core.msg.types.chat.ChatHistoryRequest msg, ClientThread client, ConcordServer server)
      Specified by:
      handle in interface MessageHandler<nl.andrewl.concord_core.msg.types.chat.ChatHistoryRequest>
    • handleIdRequest

      private void handleIdRequest(ClientThread client, Channel channel, String id)
      Handles a request for a single message from a channel.
      Parameters:
      client - The client who's requesting the data.
      channel - The channel in which to search for the message.
      id - The id of the message.
    • getResponse

      private nl.andrewl.concord_core.msg.types.chat.ChatHistoryResponse getResponse(Channel channel, long count, Long from, Long to)
      Gets a response for a standard chat history request, using a standard set of parameters.
      Parameters:
      channel - The channel to get chat history from.
      count - The number of messages to retrieve.
      from - If not null, only include messages made after this timestamp.
      to - If not null, only include messages made before this timestamp.
      Returns:
      A chat history response.
    • read

      private nl.andrewl.concord_core.msg.types.chat.Chat read(org.dizitart.no2.Document doc)
      Helper method to read a Chat from a document retrieved from a collection.
      Parameters:
      doc - The document to read.
      Returns:
      The chat that was read.
    • getOrDefault

      private Long getOrDefault(Map<String,String> params, String key, Long defaultValue)
      Helper method to get a long value or fall back to a default.
      Parameters:
      params - The parameters to check.
      key - The key to get the value for.
      defaultValue - The default value to return if no value exists.
      Returns:
      The value that was found, or the default value.