|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
ClientServer.ClientServerThread
Handles new client connections.
| Nested Class Summary | |
class |
ClientServer.ClientServerThread.TelnetInputReader
This class handles the input gathering and processing functions as well as the required echoing. |
| Field Summary | |
private Socket |
client
|
private ClientServer |
cserv
|
private BufferedInputStream |
in
|
private PrintWriter |
out
|
(package private) String |
password
|
(package private) String |
username
|
(package private) boolean |
validUser
|
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
ClientServer.ClientServerThread(Socket _client,
ClientServer _cserv)
Constructs the thread. |
|
| Method Summary | |
private int |
dropDrink(String username,
int slot,
int delay)
Attempt to drop a drink, checking both user balance and slot quantity first. |
private void |
negotiate(PrintWriter out)
Performs the telnet negotiation. |
private void |
printOptions()
Prints the options the user has. |
private void |
printSlots()
Print the contents of the drink machine and then the users balance. |
void |
run()
This is the meat of the client. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private Socket client
private ClientServer cserv
private PrintWriter out
private BufferedInputStream in
String username
String password
boolean validUser
| Constructor Detail |
public ClientServer.ClientServerThread(Socket _client,
ClientServer _cserv)
_client - The socket to the client_cserv - The ClientServer we interact with to inc/dec the number
of connected clients| Method Detail |
public void run()
private void negotiate(PrintWriter out)
throws IOException
out - The PrintWriter that we write to.
IOException
private int dropDrink(String username,
int slot,
int delay)
throws IOException
username - The username to charge for the drinkslot - The slot to dropdelay - The delay (in seconds) to wait before dropping
IOExceptionprivate void printOptions()
private void printSlots()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||