This class listening on Socket
and waiting for your command, puts given String
to all command handlers and sends back to user through the net.
Instance of this class is created by ConnectionHandlerImpl
after receiving new connection request in SocketListener
. It contains one own implementation of CommandHandlerIfc
for handling some sort of internal command such as 'quit', 'help', 'who' and so on...
At the moment command shel is very simple but it is possible to add command history feature, more inteligent input, shortcut for last command and so on.
Created: Thu Jan 10 16:35:05 2002
Definition at line 66 of file ConnectionServer.java.
Public Methods | |
ConnectionServer (Socket socket, List command_handlers) throws IOException | |
Creates a new ConnectionServer instance and setting up connection to client. | |
void | run () |
run method handles all user inputs and sends commands output back to user. | |
Protected Methods | |
void | asyncMessage (String msg) |
asyncMessage method was added for support asynchronously sending messages from server to all connected clients. | |
boolean | processCommand (String line) |
processCommand method hadles processing command actions. | |
void | log (String msg) |
log method is simple logging method. | |
Protected Attributes | |
Socket | my_socket = null |
Variable my_socket keeps socket for this active connection. | |
BufferedReader | inst = null |
Variable inst keeps input strean from user indeed. | |
PrintWriter | out = null |
Variable out is output stream de-facto. | |
List | comm_handl = null |
Variable comm_handl is a List keeping all available command handlers. | |
LogIfc | log_impl = null |
Variable log_impl contains reference to logging class implementation. | |
boolean | prompt = true |
Variable prompt is a switch which tell me whenever to print command prompt or not. | |
boolean | echo = true |
Variable echo simple switch which tells me if I am in 'echo' mode on or off. | |
Static Protected Attributes | |
List | active_connections |
This static variable active_connections contains list of all active connections at the time. |
|
Creates a new At the and it prints command prompt and waits for user input.
Definition at line 153 of file ConnectionServer.java. |
|
Please beware of using this feature.
Your application may not know how many remote consoles are active and in what states are they. But if you use this method you will send asynchronously message to connected client. It is application responsibility to not send Definition at line 235 of file ConnectionServer.java. |
|
Definition at line 267 of file ConnectionServer.java. |
|
Searches all command handlers and passes to them received command string. As a result prints back to user commands handlers results.
Definition at line 247 of file ConnectionServer.java. |
|
Definition at line 177 of file ConnectionServer.java. |
|
Initial value:
Collections.synchronizedList(new ArrayList())
active_connections contains list of all active connections at the time.
It allows to list all active connections by any user and allow to close active connection which is not used anymore.<br/> Next version I am going to add simple messages system to allow communicate between users on different connections. I am not sure if it is really needed. Definition at line 75 of file ConnectionServer.java. |
|
Variable
Every command received from user is handled against all available command handlers. So it is very likely that if more than one command handler has defined handler for given command output will be summed - concatenated Definition at line 106 of file ConnectionServer.java. |
|
Variable In general echo mode on is required for use Remote Console with MSWindows 'telnet'.
Echo mode on is default because with out it, working with MSWin is almost impossible.<br/> On the other side there is CygWin project which provides Unix like environment under MSWin and his 'telnet' which generally doesn't require echo from I don't know how other 'telnets' works from other systems. Definition at line 142 of file ConnectionServer.java. |
|
Variable
I perform Definition at line 90 of file ConnectionServer.java. |
|
Variable
It is possible, however not fully implemented, to define by user new log handler and put it to Definition at line 113 of file ConnectionServer.java. |
|
Variable
Maybe it is not necessary for doing his work by Definition at line 84 of file ConnectionServer.java. |
|
Variable All output to user is written to this output. Additionally in echo mode on user input is sent back to this output stream too. Definition at line 96 of file ConnectionServer.java. |
|
Variable
In general I shouldn't print command prompt when previous command processing is not finished yet. For example command handlers require additional info to complete command. At the moment there is only one such command: 'exit' which require user comfirmation: 'yes' or 'no' answer. I detect it by checking end of Definition at line 124 of file ConnectionServer.java. |