de.cgarbs.demo
Class EchoServerThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--de.cgarbs.net.LoginServerThread
              |
              +--de.cgarbs.demo.EchoServerThread

public class EchoServerThread
extends LoginServerThread

This class provides an EchoServer. It understands the SAY command and will echo everything you say back to you.

For a description of the methods please refer to the LoginServerThread class.

This class is licensed under the GNU GENERAL PUBLIC LICENSE.

Version:
0.0.1
Author:
Christian Garbs
See Also:
EchoServer, LoginServerThread

Fields inherited from class de.cgarbs.net.LoginServerThread
myServer, out
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
EchoServerThread(LoginServer myServer, java.io.PrintWriter logStream, java.util.Hashtable passwd, java.net.Socket socket)
           
 
Method Summary
protected  void doubleLogin()
          tells the client that this user is already logged on and the connection will be closed
protected  void gotUser()
          tells the client that a USER command was successful
protected  void invalidCommand()
          tells the client that the given command was invalid
protected  void login()
          tells the client that the login was successful
protected  boolean loginFailed(int failed)
          tells the client that the login was unsuccessful and decides if the connection shall be closed
protected  void noPassGiven()
          tells the client that the PASS command must be followed by a password
protected  void noUserGiven()
          tells the client that the USER command must be followed by a username
protected  void parseCommand(java.lang.String cmd, java.lang.String data)
          This method handles non-standard client commands.
protected  void prompt()
          tells the client that it can send a command
protected  void sendPass()
          tells the client to send a PASS command
protected  void sendUser()
          tells the client to send a USER command
protected  void sessionEnd()
          tells the client that the connection will be closed
protected  void sessionStart()
          tells the client that the connection is established
protected  void showHelp()
          sends a list of supported commands to the client
protected  boolean validCommand(java.lang.String cmd)
          checks whether a command sent from the client is allowed
 
Methods inherited from class de.cgarbs.net.LoginServerThread
getClientIP, getID, getUsername, log, run, shutdown
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, 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
 

Constructor Detail

EchoServerThread

public EchoServerThread(LoginServer myServer,
                        java.io.PrintWriter logStream,
                        java.util.Hashtable passwd,
                        java.net.Socket socket)
Parameters:
myServer -  
logStream -  
passwd -  
socket -  
Method Detail

showHelp

protected void showHelp()
Description copied from class: LoginServerThread
sends a list of supported commands to the client
Overrides:
showHelp in class LoginServerThread

validCommand

protected boolean validCommand(java.lang.String cmd)
Description copied from class: LoginServerThread
checks whether a command sent from the client is allowed
Overrides:
validCommand in class LoginServerThread
Tags copied from class: LoginServerThread
Parameters:
command - command from client
Returns:
true - command is valid

sessionStart

protected void sessionStart()
Description copied from class: LoginServerThread
tells the client that the connection is established
Overrides:
sessionStart in class LoginServerThread

sessionEnd

protected void sessionEnd()
Description copied from class: LoginServerThread
tells the client that the connection will be closed
Overrides:
sessionEnd in class LoginServerThread

parseCommand

protected void parseCommand(java.lang.String cmd,
                            java.lang.String data)
Description copied from class: LoginServerThread
This method handles non-standard client commands. (It does the thing your server is designed for)
Overrides:
parseCommand in class LoginServerThread
Tags copied from class: LoginServerThread
Parameters:
command - command from client (first string token)
data - data from client (all but first string token)

invalidCommand

protected void invalidCommand()
Description copied from class: LoginServerThread
tells the client that the given command was invalid
Overrides:
invalidCommand in class LoginServerThread

noUserGiven

protected void noUserGiven()
Description copied from class: LoginServerThread
tells the client that the USER command must be followed by a username
Overrides:
noUserGiven in class LoginServerThread

noPassGiven

protected void noPassGiven()
Description copied from class: LoginServerThread
tells the client that the PASS command must be followed by a password
Overrides:
noPassGiven in class LoginServerThread

gotUser

protected void gotUser()
Description copied from class: LoginServerThread
tells the client that a USER command was successful
Overrides:
gotUser in class LoginServerThread

sendUser

protected void sendUser()
Description copied from class: LoginServerThread
tells the client to send a USER command
Overrides:
sendUser in class LoginServerThread

sendPass

protected void sendPass()
Description copied from class: LoginServerThread
tells the client to send a PASS command
Overrides:
sendPass in class LoginServerThread

doubleLogin

protected void doubleLogin()
Description copied from class: LoginServerThread
tells the client that this user is already logged on and the connection will be closed
Overrides:
doubleLogin in class LoginServerThread

login

protected void login()
Description copied from class: LoginServerThread
tells the client that the login was successful
Overrides:
login in class LoginServerThread

loginFailed

protected boolean loginFailed(int failed)
Description copied from class: LoginServerThread
tells the client that the login was unsuccessful and decides if the connection shall be closed
Overrides:
loginFailed in class LoginServerThread
Tags copied from class: LoginServerThread
Parameters:
cnt - number of failed logins so far
Returns:
true - the connection to the client will be closed

prompt

protected void prompt()
Description copied from class: LoginServerThread
tells the client that it can send a command
Overrides:
prompt in class LoginServerThread