|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Thread
|
+--irssibot.core.OutputQueue
This class represents a buffered output queue for a server connection. It includes functionality for queuing mode pushes and traffic to the server.
IRC servers have a 1024 -byte buffer for each client (this might be outdated but should be accurate enough) and that buffer may not be overflown or else the client is disconnected with 'Excess Flood'.
ModeQueueElement| Field Summary | |
private boolean |
alive
Indicates whether this queueing thread is running or not. |
private int |
intervalBytes
Number of bytes sent during this interval |
private long |
intervalStarted
Point of time when the current output flush interval started |
private long |
lastModeFlushTime
Time of last mode flush |
private static long |
modeFlushInterval
Length of mode flushing interval (in milliseconds). |
private java.util.Hashtable |
modeQueue
A Hashtable containing Vector objects as mode queues. |
private static java.lang.String |
moduleName
|
private java.io.BufferedOutputStream |
out
Output stream for server connection |
private long |
outFlushTime
Time interval (in milliseconds) during which max . outMaxBytes bytes
are allowed to be sent to the server. |
private java.lang.Object |
outLock
Lock object for queue operations |
private int |
outMaxBytes
Maximum number of bytes to be sent to the server during a outFlushTime ms time period. |
private java.util.Vector |
outQueue
The actual output queue. |
private static long |
waitPeriod
Timeout value (in milliseconds) for wait() in main loop. |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
OutputQueue(java.io.BufferedOutputStream out,
long outFlushTime,
int outMaxBytes)
|
|
| Method Summary | |
private void |
doModeFlush(java.lang.String channelName,
java.util.Vector queue)
Flushes the mode queue to the server. |
private boolean |
doOutput()
Flushes output queue to the server at maximum rate of outMaxBytes bytes per outFlushTime
time interval (ms). |
void |
killQueue()
Kills the queue |
void |
output(java.lang.String line)
Adds an output line (irc command) to output queue. |
void |
priorityOutput(java.lang.String line)
Outputs a line straight to the server past the queue. |
void |
pushMode(ModeQueueElement element)
Pushes a mode to a channel's mode queue. |
void |
run()
After certain interval flushes the mode queue. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private static java.lang.String moduleName
private static final long modeFlushInterval
private static final long waitPeriod
private long lastModeFlushTime
private java.io.BufferedOutputStream out
private java.util.Hashtable modeQueue
private java.util.Vector outQueue
String objects
whose content is irc commands to be sent to the server.
private long outFlushTime
outMaxBytes bytes
are allowed to be sent to the server.
private int outMaxBytes
outFlushTime ms time period.
private java.lang.Object outLock
private long intervalStarted
System.currentTimeMillis()private int intervalBytes
private boolean alive
| Constructor Detail |
public OutputQueue(java.io.BufferedOutputStream out,
long outFlushTime,
int outMaxBytes)
| Method Detail |
public java.lang.String toString()
toString in class java.lang.Threadpublic void priorityOutput(java.lang.String line)
line - output linepublic void output(java.lang.String line)
outMaxBytes are discarded without notice.
line - output lineprivate boolean doOutput()
outMaxBytes bytes per outFlushTime
time interval (ms).
NOTE: this method is synchronized from outside (in run())
to outLock.
outLock,
run()public void pushMode(ModeQueueElement element)
element - the ModeQueueElement for the new modeModeQueueElement
private void doModeFlush(java.lang.String channelName,
java.util.Vector queue)
channelName - name of channel whose mode queue to pushqueue - mode queue for the channelpublic void run()
outMaxBytes bytes
per outFlushTime time interval (ms).
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void killQueue()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||