|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object triptracker.server.ClientHandler
public abstract class ClientHandler
Message handler for connected clients.
Field Summary | |
---|---|
protected PersistenceAdapter |
db
|
protected BufferedReader |
in
|
protected InputStream |
inStream
|
protected PrintStream |
out
|
protected OutputStream |
outStream
|
protected Route |
route
|
protected Server |
server
|
protected User |
user
|
Constructor Summary | |
---|---|
protected |
ClientHandler(Server server,
Socket socket,
User user)
Sets up socket streams for client communication and creates the message reader thread for message processing. |
Method Summary | |
---|---|
protected Route |
getActiveRoute()
Returns the currently active route for this client handler. |
protected void |
log(String message)
This method is used for logging messages on the server. |
protected abstract boolean |
messageHandler(String message)
Invoked when a new message has been recieved. |
protected void |
messageLoop()
Checks for messages recieved from the server, and pass them to the message handler for further processing. |
protected void |
sendMessage(Object... message)
Sends a message to the client. |
protected void |
sendMessage(OutputStream out,
Object... message)
Uses method in protocol to send message to client. |
protected void |
sendZipMessage(OutputStream out,
Object... message)
Sends compressed data to client. |
protected void |
startHandler()
Start the socket data reader thread. |
protected void |
stopHandler()
Invoked when the client has disconnected. |
protected void |
viewRoutes(String username)
Get all routes from a specific user send them to the reciever. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PersistenceAdapter db
protected Server server
protected User user
protected Route route
protected final InputStream inStream
protected final OutputStream outStream
protected final BufferedReader in
protected final PrintStream out
Constructor Detail |
---|
protected ClientHandler(Server server, Socket socket, User user) throws IOException
server
- main server instancesocket
- client communication socketuser
- client user data
IOException
- on connection failureMethod Detail |
---|
protected void stopHandler()
protected void startHandler()
protected void messageLoop() throws IOException
IOException
protected abstract boolean messageHandler(String message)
message
- received message from clientprotected void viewRoutes(String username)
username
- username to get routes fromprotected void sendMessage(OutputStream out, Object... message)
out
- output streammessage
- fieldsprotected void sendMessage(Object... message)
message
- message to sendprotected void sendZipMessage(OutputStream out, Object... message)
out
- output streammessage
- fieldsprotected void log(String message)
message
- log messageprotected Route getActiveRoute()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |