FileTransfer.v1_1
Class FTClient

java.lang.Object
  |
  +--PaP.Actor
        |
        +--PaP.ApplicationActor
              |
              +--FileTransfer.v1_1.FTClient
All Implemented Interfaces:
ActorInterface, ControlInterface, java.rmi.Remote, java.io.Serializable

public class FTClient
extends ApplicationActor

FTClient is the actor used in the FileTransfer application. It receives requests from other FTClients and sends requests based on the interaction between the user and the FTClientWindow. The ApplicationMessages sent are of one of the predefined types. The fileinfo property contains information about the current filetransfer.

Version:
1.0
Author:
Lars Erik Liljebäck
See Also:
Serialized Form

Inner Class Summary
 class FTClient.CloseWindowThread
          This thread is started when an ActorPlugOut request is received.
 
Field Summary
private  java.lang.String CANCEL_FILE_TRANSFER
           
private  java.lang.String FILE_TRANSFER
           
private  java.lang.String FILE_TRANSFER_FINISHED
           
private  java.lang.String FILE_TRANSFER_REJECT
           
private  java.lang.String FILE_TRANSFER_REQUEST
           
private  java.util.ArrayList fileInfo
          ArrayList with information about the current filetransfer.
private  RoleSession fileTransferRoleSession
          The rolesession used for filetransfer.
private  boolean initiated
          Indicates wether initial ActorPlugIn has been performed or not
private  java.lang.String RESUME_FILE_TRANSFER
           
private  FTClientWindow window
          Reference to the GUI
 
Fields inherited from class PaP.Actor
bf, context, fh
 
Constructor Summary
FTClient()
          Creates a new filetransfer client.
 
Method Summary
 RequestResult applicationActorEntry(RequestPars rpars)
          This method is the common entry point for all external requests to this actor.
 void cancelFileTransfer()
          Sends a message to another FTClient via the fileTransferRoleSession notifying him that the current filetransfer has been cancelled by this FTClient.
 void closeApplication()
          This method is used by the FTClientWindow to notify that the user wants to close the application.
 void dbg(java.lang.String dbg)
          Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities.
 void sendFileTransferFinished()
          Sends a message to another FTClient via the fileTransferRoleSession notifying him that the current filetransfer is finished.
 boolean sendFileTransferRequest(java.lang.String ftclient, java.lang.String filename, long filesize)
          Sends a request to the specified FTClient asking him if he wants to receive the specified file.
 void setFileInfo(java.util.ArrayList fi)
          Sets the current fileInfo.
 void transferBytes(byte[] bytes)
          Sends part of a file to another FTClient in the form of a byte array.
 
Methods inherited from class PaP.ApplicationActor
actorBehaviourPlugIn, actorBehaviourPlugOut, actorCapabilities, actorChangeBehaviour, actorEntry, actorPlay, actorPlugIn, actorPlugOut, anyOtherRequestType, callActorChangeBehaviour, control, init, loginUser, logoutUser, playChangesPlugIn, playPlugIn, playPlugOut, requestToActor, roleFigurePlugIn, roleFigurePlugOut, roleSessionAction, sessionResume, sessionSuspend, sessionUpdate, subscribeCancel, subscribeReport, subscribeRequest
 
Methods inherited from class PaP.Actor
findRoleSession, getGAI, start, status, term
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

FILE_TRANSFER_REQUEST

private final java.lang.String FILE_TRANSFER_REQUEST

FILE_TRANSFER_REJECT

private final java.lang.String FILE_TRANSFER_REJECT

FILE_TRANSFER

private final java.lang.String FILE_TRANSFER

FILE_TRANSFER_FINISHED

private final java.lang.String FILE_TRANSFER_FINISHED

RESUME_FILE_TRANSFER

private final java.lang.String RESUME_FILE_TRANSFER

CANCEL_FILE_TRANSFER

private final java.lang.String CANCEL_FILE_TRANSFER

initiated

private boolean initiated
Indicates wether initial ActorPlugIn has been performed or not

fileTransferRoleSession

private RoleSession fileTransferRoleSession
The rolesession used for filetransfer.

window

private FTClientWindow window
Reference to the GUI

fileInfo

private java.util.ArrayList fileInfo
ArrayList with information about the current filetransfer.
Constructor Detail

FTClient

public FTClient()
Creates a new filetransfer client.
Method Detail

applicationActorEntry

public RequestResult applicationActorEntry(RequestPars rpars)
                                    throws java.lang.Exception
This method is the common entry point for all external requests to this actor. It checks which type of Request was received and performs the appropriate actions based on the type.
Overrides:
applicationActorEntry in class ApplicationActor
Parameters:
rpars - Instance of RequestPars which specifies type of request and additional parametres to the request.
Returns:
An instance of RequestResult which indicates success or failure in treatment of the request.
Throws:
java.lang.Exception -  

cancelFileTransfer

public void cancelFileTransfer()
                        throws java.lang.Exception
Sends a message to another FTClient via the fileTransferRoleSession notifying him that the current filetransfer has been cancelled by this FTClient.

closeApplication

public void closeApplication()
                      throws java.lang.Exception
This method is used by the FTClientWindow to notify that the user wants to close the application. The actor is plugged out.

dbg

public void dbg(java.lang.String dbg)
Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities.
Overrides:
dbg in class ApplicationActor
Parameters:
dbg - The debug information to be sent.

sendFileTransferFinished

public void sendFileTransferFinished()
                              throws java.lang.Exception
Sends a message to another FTClient via the fileTransferRoleSession notifying him that the current filetransfer is finished. Then removes the rolesession between them.

sendFileTransferRequest

public boolean sendFileTransferRequest(java.lang.String ftclient,
                                       java.lang.String filename,
                                       long filesize)
                                throws java.lang.Exception
Sends a request to the specified FTClient asking him if he wants to receive the specified file. If he accepts the FTClientWindow is notified and a TransferThread is started. If he does not accept nothing happens.
Parameters:
ftclient - The GAI of the FTClient the request is sent to.
filename - The name of the file being transferred.
filesize - The size of the file being transferred.
Returns:
Returns true if the FTClient accepts the file, false otherwise.

setFileInfo

public void setFileInfo(java.util.ArrayList fi)
Sets the current fileInfo. This is an ArrayList containing information about the file being transferred. This is stored so that if the transfer is suspended, it can later be resumed again. This information is added to the actor's state when a SessionSuspend request is received.
Parameters:
fi - The ArrayList with information about the current filetransfer.

transferBytes

public void transferBytes(byte[] bytes)
                   throws java.lang.Exception
Sends part of a file to another FTClient in the form of a byte array. The array is added to an ApplicationMessage which is sent via the fileTransferRoleSession by sending a RoleSessionAction request.
Parameters:
bytes - Byte array which constitutes the part of the file transferred.