|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
jBittorrentAPI.MessageReceiver
public class MessageReceiver
Thread created to listen for incoming message from remote peers. When data is read, message type is determined and a new Message object (either Message_HS or Message_PP) is created and passed to the corresponding receiver
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private java.io.DataInputStream |
dis
|
private boolean |
hsOK
|
private java.io.InputStream |
is
|
private javax.swing.event.EventListenerList |
listeners
|
private boolean |
run
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
MessageReceiver(java.lang.String id,
java.io.InputStream is)
Create a new Message receiver for a given peer |
Method Summary | |
---|---|
void |
addIncomingListener(IncomingListener listener)
|
protected void |
fireMessageReceived(Message m)
|
IncomingListener[] |
getIncomingListeners()
|
private int |
read(byte[] data)
Reads bytes from the DataInputStream |
private int |
read1(byte[] data)
Reads bytes from the input stream. |
void |
removeIncomingListener(IncomingListener listener)
|
void |
run()
Reads data from the inputstream, creates new messages according to the received data and fires MessageReceived method of the listeners with the new message in parameter. |
void |
stopThread()
Stops the current thread by completing the run() method |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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 |
Field Detail |
---|
private java.io.DataInputStream dis
private boolean hsOK
private java.io.InputStream is
private final javax.swing.event.EventListenerList listeners
private boolean run
Constructor Detail |
---|
public MessageReceiver(java.lang.String id, java.io.InputStream is) throws java.io.IOException
id
- The id of the peer that has been assigned this receiveris
- InputStream
java.io.IOException
Method Detail |
---|
public void addIncomingListener(IncomingListener listener)
protected void fireMessageReceived(Message m)
public IncomingListener[] getIncomingListeners()
private int read(byte[] data)
data
- byte[]
private int read1(byte[] data) throws java.io.IOException, java.lang.InterruptedException, java.lang.Exception
data
- byte[]
java.io.IOException
java.lang.InterruptedException
java.lang.Exception
public void removeIncomingListener(IncomingListener listener)
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void stopThread()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |