|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--Server.SocketThread
A thread responsible for handling all of the traffic of an open socket
Field Summary | |
private boolean |
isAfterOpenCommand
A predicate that indicates whether we are after the open command |
private SessionWrapper |
sessionWrapper
The session thread associated with this object |
private java.net.Socket |
socket
The socket associated with this socket thread. |
private java.io.BufferedReader |
sockIn
An input for the socket |
private java.io.BufferedWriter |
sockOut
An output for the socket |
private User |
user
The user associated with this socket thread |
Fields inherited from class java.lang.Thread |
contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ |
Constructor Summary | |
(package private) |
SocketThread(java.net.Socket socket)
A constructor that that associates a given socket with this object |
Method Summary | |
(package private) Session |
doAddSession(Session newSession)
Retrieve or create a session |
(package private) void |
doAddUser(User newUser,
Session session)
Retrieve or create a user |
private void |
doGetReaderWriter()
A procedure that sets the global 'sockIn' variable to wrap the socket InputStreamReader, and 'sockOut' to wrap the socket OutputStreamWriter. |
(package private) User |
doIdentifyUser()
Identify the user |
private void |
finish()
|
private SessionWrapper |
getSessionWrapper()
Returns the session thread associated with this object |
java.io.BufferedWriter |
getSockOut()
Returns a BufferedWriter output for the associated socket |
User |
getUser()
Returns the user associated with this socket thread |
private void |
handleLine(java.lang.String line)
Handle a given input line from the network; If we have identified a user-session matching, send it to the session member, otherwise, take care of authentication and book-keeping. |
private void |
handleOpenCommand(java.lang.String line)
Handle an open command |
(package private) Session |
parseOpenCommand(java.lang.String line)
A front-end to parse an open command |
void |
run()
A front-end for this thread; 1. |
private void |
setSessionThread(SessionWrapper thread)
Sets the session thread associated with this object |
private void |
setUser(User user)
Sets the user associated with this socket thread |
Methods inherited from class java.lang.Thread |
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.io.BufferedWriter sockOut
private java.io.BufferedReader sockIn
private User user
private final java.net.Socket socket
private boolean isAfterOpenCommand
private SessionWrapper sessionWrapper
Constructor Detail |
SocketThread(java.net.Socket socket)
socket
- The socket to associateMethod Detail |
private final void doGetReaderWriter()
void doAddUser(User newUser, Session session)
newUser
- The temporary user instancesession
- The session to add the user toSession doAddSession(Session newSession)
newSession
- The temporary session instanceUser doIdentifyUser()
Session parseOpenCommand(java.lang.String line)
line
- The open command stringprivate void handleOpenCommand(java.lang.String line)
line
- The open command stringprivate final void handleLine(java.lang.String line)
line
- The line to handlepublic void run()
run
in class java.lang.Thread
private void finish()
public User getUser()
private void setUser(User user)
user
- The user to associate with this socket threadpublic java.io.BufferedWriter getSockOut()
private SessionWrapper getSessionWrapper()
private void setSessionThread(SessionWrapper thread)
thread
- The thread to save
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |