FTP-Server API

server
Class UserSession

java.lang.Object
  |
  +--server.UserSession
All Implemented Interfaces:
Session
Direct Known Subclasses:
ExtendedUserSession

public abstract class UserSession
extends Object
implements Session

The class represents a session from a client. It is automatically instantiated by the server, when the client connects, and are send though the ServerObserver interface to the observers.


Field Summary
protected  HashSet obs
          All the UserSessionObservers on this UserSession
protected  int state
           
 
Constructor Summary
protected UserSession()
          ONLY a Server (Probe) can and may 'make instances' of this class!
 
Method Summary
 void abortTransmission()
          Aborts this clients current filetransmission.
 void addUserSessionObserver(UserSessionObserver userSessionObserver)
          Adds an observer
 void disconnectClient(int reasonCode)
          Kicks the client from the server, and cancels the filetransfer if any.
 InetAddress getClientInetAddress()
          Returns the clients InetAddresse
 String getClientIP()
          The clients ip.
 XMLTag getClientTag()
          Returns the clients own XMLTag.
 Vector getConversation()
          Al communication between the client and the server.
 String getLogin()
          The login name of the client
 String getLogonTime()
          The time the client logged onto the server.
 Date getLogonTimeAsDate()
          The time the client logged onto the server
 int getNumberOfRecivedFiles()
          The total number of files that has been recived from this client.
 int getNumberOfSendFiles()
          The total number of send files to this client
 int getRecivedByteTotal()
          The total number of recived bytes from this client.
 int getSendBytesInFile()
          The number of bytes, that thas been transfered in the actuel filetransfer.
 int getSendByteTotal()
          The total number of send bytes to this client.
 int getSessionNr()
          This usersessions sessionnumber
 int getSpeedInBytesPrSek()
          The number for bytes per second, that the current file are transmitted with.
 int getUserState()
          States this client can bee in (online, kicked, banned ect.)
 boolean isFileDownload()
          Whether the current file is downloading from the client or not.
 boolean isFileUpload()
          Whether the current file is upload to the client or not.
 boolean isLogedIn()
          Is the Client loged in?
 void removeUserSessionObserver(UserSessionObserver userSessionObserver)
          Removes an observer
 boolean sendingFile()
          Is there an upload/download/directorytransfer going on?
protected  void set(Session ses, Command com)
          Sets the classes references.
 void setSpeedInBytesPrSek(int bytes)
          The number of bytes, that the server may transfer to this client per second.
 void tellClient(String line)
          Writes a line to the client over the command-connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

obs

protected HashSet obs
All the UserSessionObservers on this UserSession


state

protected int state
See Also:
server.event.UserSessionObserver
Constructor Detail

UserSession

protected UserSession()
ONLY a Server (Probe) can and may 'make instances' of this class!

Method Detail

set

protected void set(Session ses,
                   Command com)
Sets the classes references. Made, because it cannot be set in the constructors, because the objects is instantiated in a certain order.

Parameters:
ses - Session
com - Command

addUserSessionObserver

public void addUserSessionObserver(UserSessionObserver userSessionObserver)
Adds an observer

Parameters:
userSessionObserver - observer

removeUserSessionObserver

public void removeUserSessionObserver(UserSessionObserver userSessionObserver)
Removes an observer

Parameters:
userSessionObserver -

getClientInetAddress

public InetAddress getClientInetAddress()
Returns the clients InetAddresse

Returns:
InetAddress

getClientIP

public String getClientIP()
Description copied from interface: Session
The clients ip.

Specified by:
getClientIP in interface Session
Returns:
ip

getClientTag

public XMLTag getClientTag()
Returns the clients own XMLTag. This can be used to find information about the client. For this purpose the Conf can be used as a service calss for some operations.

Returns:
This clients own XMLTag.

isFileUpload

public boolean isFileUpload()
Whether the current file is upload to the client or not. If nothing is currently transmitted, false are returned.

Returns:
true if the server is currently uploading. (the client is downloading)

isFileDownload

public boolean isFileDownload()
Whether the current file is downloading from the client or not. If nothing is currently transmitted, false are returned.

Returns:
true if the server is currently downloading. (the client is uploading)

getSpeedInBytesPrSek

public int getSpeedInBytesPrSek()
The number for bytes per second, that the current file are transmitted with.

Returns:
bytes per second. -1 if nothing is beeing transmitted.

setSpeedInBytesPrSek

public void setSpeedInBytesPrSek(int bytes)
The number of bytes, that the server may transfer to this client per second.

Parameters:
bytes - bytes per second

getSendBytesInFile

public int getSendBytesInFile()
The number of bytes, that thas been transfered in the actuel filetransfer.

Returns:
number of bytes. -1 if nothing is beeing transmitted.

getSendByteTotal

public int getSendByteTotal()
The total number of send bytes to this client. Directorylists are NOT included!

Returns:
antal bytes

getRecivedByteTotal

public int getRecivedByteTotal()
The total number of recived bytes from this client.

Returns:
antal bytes

getNumberOfSendFiles

public int getNumberOfSendFiles()
The total number of send files to this client

Returns:
number of send files

getNumberOfRecivedFiles

public int getNumberOfRecivedFiles()
The total number of files that has been recived from this client.

Returns:
number of recived files.

abortTransmission

public void abortTransmission()
Aborts this clients current filetransmission.


sendingFile

public boolean sendingFile()
Is there an upload/download/directorytransfer going on?

Returns:
true true if the server is currently transmitting

getSessionNr

public int getSessionNr()
This usersessions sessionnumber

Specified by:
getSessionNr in interface Session
Returns:
nr

disconnectClient

public void disconnectClient(int reasonCode)
Kicks the client from the server, and cancels the filetransfer if any.


tellClient

public void tellClient(String line)
Writes a line to the client over the command-connection. It is often a good idea to start any line by writing [200 ] (without the []), as this is undestood as a comment by the client.

Parameters:
line - The text to send to the client!

getLogin

public String getLogin()
The login name of the client

Specified by:
getLogin in interface Session
Returns:
login

getLogonTimeAsDate

public Date getLogonTimeAsDate()
The time the client logged onto the server

Returns:
time

getLogonTime

public String getLogonTime()
Description copied from interface: Session
The time the client logged onto the server. The format is: D. 23.05.2002 kl. 18:00:27

Specified by:
getLogonTime in interface Session
Returns:
date+time

getConversation

public Vector getConversation()
Description copied from interface: Session
Al communication between the client and the server.

Specified by:
getConversation in interface Session
Returns:
each object in the vector represents a line.

isLogedIn

public boolean isLogedIn()
Is the Client loged in?

Returns:
true if yes

getUserState

public int getUserState()
States this client can bee in (online, kicked, banned ect.)

Returns:
See Also:
server.event.UserSessionObserver

FTP-Server API