Server
Class User

java.lang.Object
  |
  +--Server.User

public class User
extends java.lang.Object

Each instance of the User class is an end-user, working as a client. note: user is uniquily identified by both its internet address and its name.


Field Summary
private  java.net.InetAddress inetAddress
          The internet address of the user.
private  SocketThread socketThread
          The socket this user is attached to.
private  java.lang.String userName
          The name of the user.
 
Constructor Summary
(package private) User(java.net.InetAddress inetAddress, java.lang.String userName)
          A constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
          An overriden equals() for this object.
 java.net.InetAddress getInetAddress()
          Returns the internet address of the user
 SocketThread getSocketThread()
          Returns the SocketThread associated with this user
 int hashCode()
          An overriden hashCode() for this object.
 void setSocketThread(SocketThread thread)
          Set the SocketThread associated with this user
 java.lang.String toString()
          Returns the name of the user
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

inetAddress

private final java.net.InetAddress inetAddress
The internet address of the user. Note: for security reason, this field is automatically filled with the address of the sending client. That is, a user cannot route the server packets delivered to him to a different computer by declaring a different IP address.

userName

private final java.lang.String userName
The name of the user. Initialized in the constructor.

socketThread

private SocketThread socketThread
The socket this user is attached to.
Constructor Detail

User

User(java.net.InetAddress inetAddress,
     java.lang.String userName)
A constructor. All of the identifying user fields are set here, such as IP address, etc.
Parameters:
inetAddress - The address of the user.
userName - The name of the user.
Method Detail

toString

public java.lang.String toString()
Returns the name of the user
Overrides:
toString in class java.lang.Object
Returns:
the name of the user

getInetAddress

public java.net.InetAddress getInetAddress()
Returns the internet address of the user
Returns:
the internet address of the user

equals

public boolean equals(java.lang.Object obj)
An overriden equals() for this object. Two user instances with the same internet address and the same name, will be regarded as being equal.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
An overriden hashCode() for this object. Two user instances with the same internet address and the same name, will receive the same hash code.
Overrides:
hashCode in class java.lang.Object

getSocketThread

public SocketThread getSocketThread()
Returns the SocketThread associated with this user
Returns:
the SocketThread associated with this user

setSocketThread

public void setSocketThread(SocketThread thread)
Set the SocketThread associated with this user
Parameters:
thread - The SocketThread to save