Class CMFileEvent


public class CMFileEvent extends CMEvent
This class represents CM events that are used for the file-transfer task.
  • Field Details

    • REQUEST_PERMIT_PULL_FILE

      public static final int REQUEST_PERMIT_PULL_FILE
      The event ID for requesting a file.

      event direction: receiver (requester) -> sender (file owner)

      This event is sent when the receiver calls CMStub.requestFile(String, String) or CMStub.requestFile(String, String, byte).
      The following fields are used for this event:

      See Also:
    • REPLY_PERMIT_PULL_FILE

      public static final int REPLY_PERMIT_PULL_FILE
      The event ID for the response to the file request.

      event direction: sender -> receiver

      The file owner sends this event as the response to the REQUEST_PERMIT_PULL_FILE event.
      The following fields are used for this event:

      See Also:
    • REQUEST_PERMIT_PUSH_FILE

      public static final int REQUEST_PERMIT_PUSH_FILE
      The event ID for requesting a permit to push a file.

      event direction: sender (requester) -> receiver (file owner)

      This event is sent when the sender calls CMStub.pushFile(String, String).
      The following fields are used for this event:

      See Also:
    • REPLY_PERMIT_PUSH_FILE

      public static final int REPLY_PERMIT_PUSH_FILE
      The event ID for the response to the permit-request of pushing a file.

      event direction: receiver -> sender

      The file receiver sends this event as the response to the REQUEST_PERMIT_PUSH_FILE event.
      The following fields are used for this event:

      See Also:
    • START_FILE_TRANSFER

      public static final int START_FILE_TRANSFER
      The event ID for notifying the receiver of the start of file-transfer.

      event direction: sender -> receiver

      The file owner sends this event right after it sends the REPLY_PERMIT_PULL_FILE event, or receives the REPLY_PERMIT_PUSH_FILE event with the granted permit, and if the FILE_TRANSFER_SCHEME field of the configuration file of the CM server (cm-server.conf) is set to 0.
      The following fields are used for this event:

      See Also:
    • START_FILE_TRANSFER_ACK

      public static final int START_FILE_TRANSFER_ACK
      The event ID for the response to the notification of the start of file-transfer.

      event direction: receiver -> sender

      The file receiver sends this event as the response to the START_FILE_TRANSFER event.
      The following fields are used for this event:

      See Also:
    • CONTINUE_FILE_TRANSFER

      public static final int CONTINUE_FILE_TRANSFER
      The event ID for transferring each file block.

      event direction: sender -> receiver

      The file owner starts to send this event when it receives the START_FILE_TRANSFER_ACK event. This event is repeatedly sent for each file block until all file blocks are sent to the receiver.
      The following fields are used for this event:

      See Also:
    • CONTINUE_FILE_TRANSFER_ACK

      public static final int CONTINUE_FILE_TRANSFER_ACK
      See Also:
    • END_FILE_TRANSFER

      public static final int END_FILE_TRANSFER
      The event ID for notifying the receiver of the end of file-transfer.

      event direction: sender -> receiver

      The file owner sends this event after it sends the last CONTINUE_FILE_TRANSFER event.
      The following fields are used for this event:

      See Also:
    • END_FILE_TRANSFER_ACK

      public static final int END_FILE_TRANSFER_ACK
      The event ID for the response to the notification of the end of file-transfer.

      event direction: receiver -> sender

      The file receiver sends this event as the response to the END_FILE_TRANSFER event.
      The following fields are used for this event:

      See Also:
    • REQUEST_DIST_FILE_PROC

      public static final int REQUEST_DIST_FILE_PROC
      See Also:
    • CANCEL_FILE_SEND

      public static final int CANCEL_FILE_SEND
      The event ID for the cancellation of pushing (or sending) a file.

      event direction: sender -> receiver

      The file sender sends this event when it calls CMStub.cancelPushFile(String), and if the FILE_TRANSFER_SCHEME field of the configuration file of the CM server (cm-server.conf) is set to 0.
      The following fields are used for this event:

      See Also:
    • CANCEL_FILE_SEND_ACK

      public static final int CANCEL_FILE_SEND_ACK
      The event ID for the response to the cancellation of sending a file.

      event direction: receiver -> sender

      The receiver sends this event as the response to the CANCEL_FILE_SEND event.
      The following fields are used for this event:

      See Also:
    • START_FILE_TRANSFER_CHAN

      public static final int START_FILE_TRANSFER_CHAN
      The event ID for notifying the receiver of the start of file-transfer.

      event direction: sender -> receiver

      The file owner sends this event right after it sends the REPLY_PERMIT_PULL_FILE event, or receives the REPLY_PERMIT_PUSH_FILE event with the granted permit and if the FILE_TRANSFER_SCHEME field of the configuration file of the CM server (cm-server.conf) is set to 1.
      The following fields are used for this event:

      See Also:
    • START_FILE_TRANSFER_CHAN_ACK

      public static final int START_FILE_TRANSFER_CHAN_ACK
      The event ID for the response to the notification of the start of file-transfer.

      event direction: receiver -> sender

      The file receiver sends this event as the response to the START_FILE_TRANSFER_CHAN event.
      The following fields are used for this event:

      See Also:
    • END_FILE_TRANSFER_CHAN

      public static final int END_FILE_TRANSFER_CHAN
      The event ID for notifying the receiver of the end of file-transfer.

      event direction: sender -> receiver

      The file owner sends this event after it sends the last file block, and if the FILE_TRANSFER_SCHEME field of the configuration file of the CM server (cm-server.conf) is set to 1.
      The following fields are used for this event:

      See Also:
    • END_FILE_TRANSFER_CHAN_ACK

      public static final int END_FILE_TRANSFER_CHAN_ACK
      The event ID for the response to the notification of the end of file-transfer.

      event direction: receiver -> sender

      The file receiver sends this event as the response to the END_FILE_TRANSFER_CHAN event.
      The following fields are used for this event:

      See Also:
    • CANCEL_FILE_SEND_CHAN

      public static final int CANCEL_FILE_SEND_CHAN
      The event ID for the cancellation of pushing (or sending) a file.

      event direction: sender -> receiver

      The file sender sends this event when it calls CMStub.cancelPushFile(String), and if the FILE_TRANSFER_SCHEME field of the configuration file of the CM server (cm-server.conf) is set to 1.
      The following fields are used for this event:

      See Also:
    • CANCEL_FILE_SEND_CHAN_ACK

      public static final int CANCEL_FILE_SEND_CHAN_ACK
      The event ID for the response to the cancellation of sending a file.

      event direction: receiver -> sender

      The receiver sends this event as the response to the CANCEL_FILE_SEND_CHAN event.
      The following fields are used for this event:

      See Also:
    • CANCEL_FILE_RECV_CHAN

      public static final int CANCEL_FILE_RECV_CHAN
      The event ID for the cancellation of receiving a file.

      event direction: receiver -> sender

      The file receiver sends this event when it calls CMStub.cancelPullFile(String), and if the FILE_TRANSFER_SCHEME field of the configuration file of the CM server (cm-server.conf) is set to 1.
      The following fields are used for this event:

      See Also:
    • CANCEL_FILE_RECV_CHAN_ACK

      public static final int CANCEL_FILE_RECV_CHAN_ACK
      The event ID for the response to the cancellation of receiving a file.

      event direction: sender -> receiver

      The file sender sends this event as the response to the CANCEL_FILE_RECV_CHAN event.
      The following fields are used for this event:

      See Also:
    • ERR_SEND_FILE_CHAN

      public static final int ERR_SEND_FILE_CHAN
      See Also:
    • ERR_RECV_FILE_CHAN

      public static final int ERR_RECV_FILE_CHAN
      See Also:
  • Constructor Details

    • CMFileEvent

      public CMFileEvent()
    • CMFileEvent

      public CMFileEvent(ByteBuffer msg)
  • Method Details

    • setFileReceiver

      public void setFileReceiver(String uName)
    • getFileReceiver

      public String getFileReceiver()
      Returns the receiver name of a file.
      Returns:
      receiver name
    • setFileSender

      public void setFileSender(String sName)
    • getFileSender

      public String getFileSender()
      Returns the sender name of a file.
      Returns:
      sender name
    • setFileName

      public void setFileName(String fName)
    • getFileName

      public String getFileName()
      Returns the file name.
      Returns:
      file name
    • setFilePath

      public void setFilePath(String fPath)
    • getFilePath

      public String getFilePath()
      Returns the file path.
      Returns:
      file path at the sender node
    • setFileSize

      public void setFileSize(long fSize)
    • getFileSize

      public long getFileSize()
      Returns the file size.
      Returns:
      file size (number of bytes)
    • setReceivedFileSize

      public void setReceivedFileSize(long fSize)
    • getReceivedFileSize

      public long getReceivedFileSize()
      Returns the size of a file that already has been received.
      Returns:
      received size of a file (number of bytes)
    • setReturnCode

      public void setReturnCode(int code)
    • getReturnCode

      public int getReturnCode()
      Returns the return code.
      Returns:
      1 if a corresponding request is successfully processed; 0 otherwise.
    • setFileBlock

      public void setFileBlock(byte[] fBlock)
    • getFileBlock

      public byte[] getFileBlock()
      Returns the file block.
      Returns:
      file block (bytes)
    • setBlockSize

      public void setBlockSize(int bSize)
    • getBlockSize

      public int getBlockSize()
      Returns the size of file block.
      Returns:
      size of file block (number of bytes)
    • setContentID

      public void setContentID(int id)
    • getContentID

      public int getContentID()
      Returns the identifier of SNS content that attaches a file.
      Returns:
      SNS content ID
    • setFileAppendFlag

      public void setFileAppendFlag(byte flag)
    • getFileAppendFlag

      public byte getFileAppendFlag()
      Returns the file transfer mode.
      Returns:
      1 if the append mode is on; 0 if overwrite mode is on.
    • setSSCPort

      public void setSSCPort(int nPort)
    • getSSCPort

      public int getSSCPort()
      Returns the port number of (client) file receiver.

      If the FILE_TRANSFER_SCHEME of the server CM configuration file (cm-server.conf) is 1 and both the file sender and receiver are the client type (P2P file-transfer), the file sender connects to the receiver by opening a blocking socket channel with the IP address and this port number of the receiver.

      Returns:
      port number of file receiver.
    • getByteNum

      protected int getByteNum()
      Overrides:
      getByteNum in class CMEvent
    • marshallBody

      protected void marshallBody()
      Specified by:
      marshallBody in class CMEvent
    • unmarshallBody

      protected void unmarshallBody(ByteBuffer msg)
      Specified by:
      unmarshallBody in class CMEvent
    • toString

      public String toString()
      Overrides:
      toString in class CMEvent