|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--Chat.Sender
A sender thread. Reads commands from the console and processes
them sychronously, creating connections to other machines and
updating Console
and HostList
objects.
Receiver
,
Console
,
HostList
Field Summary | |
private Console |
console
The link to common console. |
private HostList |
hostlist
The link to common host list. |
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) |
Sender(Console console,
HostList hostlist)
Initializes the sender thread with the link to console and host list. |
Method Summary | |
private boolean |
connect(java.lang.String host,
int port,
boolean silent)
Connects to host specified and fills the hostlist with the data returned. |
private void |
connect(java.lang.String script,
java.lang.String room)
Registers this host on the server, and tries to connect to one of the hosts on the list returned. |
private void |
disconnect()
Disconnects from the network. |
private void |
file(java.lang.String name)
Sends a file to all the users from the hostlist, but not myself. |
private void |
message(java.lang.String text)
Sends a chat message to all the users, including myself. |
private boolean |
process(java.lang.String line)
Process a command from the console. |
boolean |
processHandled(java.lang.String line)
Process a command from the console and handle caught exceptions |
void |
run()
Sender thread's body. |
private void |
send(HostList.HostItem item,
java.lang.String message)
Send a prepared message to one remote user. |
private void |
send2all(java.lang.String message)
Send a prepared message to all users from the host list (excluding myself). |
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 final Console console
private final HostList hostlist
Constructor Detail |
Sender(Console console, HostList hostlist)
console
- link to console.hostlist
- link to hostlist.Method Detail |
private void send(HostList.HostItem item, java.lang.String message) throws java.io.IOException
item
- remote host identification.message
- a string to be sent.private void send2all(java.lang.String message) throws java.io.IOException
message
- a string to be sent.private void connect(java.lang.String script, java.lang.String room) throws java.io.IOException
script
- server URL.room
- a name of the room.private boolean connect(java.lang.String host, int port, boolean silent) throws java.io.IOException
host
- host IP or host name.port
- host port.silent
- don't print errors, just return the result.private void disconnect() throws java.io.IOException
private void message(java.lang.String text) throws java.io.IOException
text
- a message to be send.private void file(java.lang.String name) throws java.io.IOException
name
- a name of the file.private boolean process(java.lang.String line) throws java.io.IOException
line
- the command.public boolean processHandled(java.lang.String line)
line
- the command.public void run()
run
in class java.lang.Thread
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |