de.grogra.imp.net
Class Connection

java.lang.Object
  extended by de.grogra.imp.net.Connection
All Implemented Interfaces:
java.lang.Runnable

public class Connection
extends java.lang.Object
implements java.lang.Runnable


Constructor Summary
Connection(java.net.Socket socket)
           
 
Method Summary
 void addMessageHandler(MessageHandler h)
           
 long beginMessage(java.lang.String message, ResponseHandler rh)
           
 long beginResponse(long requestId, ResponseHandler rh)
           
 void close()
           
 void consumeByte(int value)
           
 void consumeInt(int value)
           
 void end(long messageId)
           
 java.io.DataInputStream getIn()
           
 java.io.DataOutputStream getOut()
           
 java.net.Socket getSocket()
           
protected  boolean handleMessage(long messageId, java.lang.String message, boolean checkAvailability)
           
 SimpleResponseHandler isAvailable(java.lang.String message)
           
 boolean isClosed()
           
 void removeMessageHandler(MessageHandler h)
           
 void run()
           
 void skipRest()
           
 void start()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Connection

public Connection(java.net.Socket socket)
           throws java.io.IOException
Throws:
java.io.IOException
Method Detail

addMessageHandler

public void addMessageHandler(MessageHandler h)

beginMessage

public long beginMessage(java.lang.String message,
                         ResponseHandler rh)
                  throws java.io.IOException
Throws:
java.io.IOException

beginResponse

public long beginResponse(long requestId,
                          ResponseHandler rh)
                   throws java.io.IOException
Throws:
java.io.IOException

close

public void close()

consumeByte

public void consumeByte(int value)
                 throws java.io.IOException
Throws:
java.io.IOException

consumeInt

public void consumeInt(int value)
                throws java.io.IOException
Throws:
java.io.IOException

end

public void end(long messageId)
         throws java.io.IOException
Throws:
java.io.IOException

getIn

public java.io.DataInputStream getIn()

getOut

public java.io.DataOutputStream getOut()

getSocket

public java.net.Socket getSocket()

handleMessage

protected boolean handleMessage(long messageId,
                                java.lang.String message,
                                boolean checkAvailability)
                         throws java.io.IOException
Throws:
java.io.IOException

isAvailable

public SimpleResponseHandler isAvailable(java.lang.String message)
                                  throws java.io.IOException
Throws:
java.io.IOException

isClosed

public boolean isClosed()

removeMessageHandler

public void removeMessageHandler(MessageHandler h)

run

public void run()
Specified by:
run in interface java.lang.Runnable

skipRest

public void skipRest()
              throws java.io.IOException
Throws:
java.io.IOException

start

public void start()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object