Class FileHandler

java.lang.Object
com.cloud.serverpak.handlers.FileHandler

public class FileHandler extends Object
Class listener of messages carrying file data. Defines a method for work with a message containing the file data.
  • Field Details

    • mainHandler

      private final MainHandler mainHandler
      Netty's main listener.
      See Also:
    • fileService

      private final FilesInformService fileService
      File information service.
      See Also:
    • fos

      private FileOutputStream fos
      Output stream to a file.
    • append

      private boolean append
      Marker defining the mode of writing to the file (whether to append the data to the end of the file or overwrite it.)
  • Constructor Details

    • FileHandler

      public FileHandler(MainHandler mainHandler)
      The constructor saves the main listener reference.
      Parameters:
      mainHandler - Netty's main listener.
  • Method Details

    • fileHandle

      public void fileHandle(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Receives a message with file data, checks whether the file fits into 1 message. If not, then sets the "append" marker to "true" mode to record data from follow-up messages to the end of the file. After receiving the last part of the file in the message closes the output stream to the file. Sends a service message to the client with updated storage status data.
      Parameters:
      ctx - channel context.
      msg - the message object.
      See Also: