|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--ocsf.server.ConnectionToClient
An instance of this class is created by the server when a client connects. It accepts messages coming from the client and is responsible for sending data to the client since the socket is private to this class. The AbstractServer contains a set of instances of this class and is responsible for adding and deleting them.
Project Name: OCSF (Object Client-Server Framework)
Field Summary | |
private java.net.Socket |
clientSocket
Sockets are used in the operating system as channels of communication between two processes. |
private java.io.ObjectInputStream |
input
Stream used to read from the client. |
private java.io.ObjectOutputStream |
output
Stream used to write to the client. |
private boolean |
readyToStop
Indicates if the thread is ready to stop. |
private java.util.HashMap |
savedInfo
Map to save information about the client such as its login ID. |
private AbstractServer |
server
A reference to the Server that created this instance. |
Fields inherited from class java.lang.Thread |
contextClassLoader,
daemon,
eetop,
group,
inheritedAccessControlContext,
MAX_PRIORITY,
MIN_PRIORITY,
name,
NORM_PRIORITY,
priority,
single_step,
stillborn,
stopThreadPermission,
target,
threadInitNumber,
threadQ,
values |
Constructor Summary | |
(package private) |
ConnectionToClient(java.lang.ThreadGroup group,
java.net.Socket clientSocket,
AbstractServer server)
Constructs a new connection to a client. |
Method Summary | |
void |
close()
Closes the client. |
private void |
closeAll()
Closes all connection to the server. |
protected void |
finalize()
This method is called by garbage collection. |
java.net.InetAddress |
getInetAddress()
Returns the address of the client. |
java.lang.Object |
getInfo(java.lang.String infoType)
Returns information about the client saved using setInfo. |
void |
run()
Constantly reads the client's input stream. |
void |
sendToClient(java.lang.Object msg)
Sends an object to the client. |
void |
setInfo(java.lang.String infoType,
java.lang.Object info)
Saves arbitrary information about this client. |
java.lang.String |
toString()
Returns a string representation of the client. |
Methods inherited from class java.lang.Thread |
|
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
private AbstractServer server
private java.net.Socket clientSocket
Socket
private java.io.ObjectInputStream input
private java.io.ObjectOutputStream output
private boolean readyToStop
private java.util.HashMap savedInfo
Constructor Detail |
ConnectionToClient(java.lang.ThreadGroup group, java.net.Socket clientSocket, AbstractServer server) throws java.io.IOException
group
- the thread group that contains the connections.clientSocket
- contains the client's socket.server
- a reference to the server that created
this instanceMethod Detail |
public final void sendToClient(java.lang.Object msg) throws java.io.IOException
msg
- the message to be sent.public final void close() throws java.io.IOException
public final java.net.InetAddress getInetAddress()
public java.lang.String toString()
public void setInfo(java.lang.String infoType, java.lang.Object info)
infoType
- identifies the type of informationinfo
- the information itself.public java.lang.Object getInfo(java.lang.String infoType)
infoType
- identifies the type of informationpublic final void run()
private void closeAll() throws java.io.IOException
protected void finalize()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |