public abstract class UserDefinedDaemon
extends java.lang.Object
Constructor and Description |
---|
UserDefinedDaemon()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
enableEvents()
This method enables processing of events.
You must call this method from initDaemon .If enabled, the onEvent method will be called
for each new event in the SWATH event queue. |
void |
enableIncomingText()
This method enables processing of incoming text.
You must call this method from initDaemon .If enabled, the onText method will be called
when there is new text from the game server. |
void |
endDaemon()
Called by the framework when the daemon is shut down.
You can override this method to clean up after the daemon if needed. |
java.lang.String |
getClassName()
Gets the class name.
|
java.lang.String |
getName()
Called by the framework to get the name of the daemon.
You should override this method. |
java.net.URL |
getResource(java.lang.String resource)
Finds a resource with a given name.
|
boolean |
initDaemon()
Called by the framework to initialise the daemon.
You should override this method to make your own initialisation. |
void |
onEvent(EventIfc event)
This method is called for each posted event.
You can override this method to handle events. |
void |
onText(java.lang.String buffer,
java.lang.String text)
This method is called when new text has arrived from the game server.
You can override this method to handle incoming text. You must call setIncomingTextMode to enable this callback method.The current text buffer contains both the previous text and the new text that just arrived. |
void |
onTimer(java.util.Date time)
This method is called when the timer is triggered.
|
void |
postEvent(UserDefinedEvent event)
This method posts an event in the SWATH event queue.
|
void |
printTrace(java.lang.Exception e)
Print an exception and the complete stack trace
in the SWATH console window.
|
void |
printTrace(java.lang.String text)
Print trace text in the SWATH console window.
|
void |
setBufferText(java.lang.String text)
Sets the current text buffer content.
|
void |
setTimer(java.util.Date time)
This method sets the timer.
|
void |
setTimer(long delay)
This method sets the timer to the current time plus the delay.
|
void |
skipBufferText(int count)
Removes characters from the current text buffer.
|
public final java.lang.String getClassName()
public final java.net.URL getResource(java.lang.String resource)
resource
- The name of the wanted resource.null
if not found.public final void enableEvents()
initDaemon
.onEvent
method will be called
for each new event in the SWATH event queue.onEvent(com.swath.EventIfc)
,
initDaemon()
public final void enableIncomingText()
initDaemon
.onText
method will be called
when there is new text from the game server.onText(java.lang.String, java.lang.String)
,
initDaemon()
public final void skipBufferText(int count)
count
- Number of characters to remove.setBufferText(java.lang.String)
,
onText(java.lang.String, java.lang.String)
public final void setBufferText(java.lang.String text)
text
- The new content.skipBufferText(int)
,
onText(java.lang.String, java.lang.String)
public final void postEvent(UserDefinedEvent event)
event
- The event to post.public final void setTimer(java.util.Date time)
time
- When the timer should trigger or
null
to reset the timer.onTimer(java.util.Date)
,
setTimer(long)
public final void setTimer(long delay)
delay
- The delay in milliseconds.onTimer(java.util.Date)
,
setTimer(Date)
public final void printTrace(java.lang.String text) throws java.lang.Exception
text
- The text to print.java.lang.Exception
public final void printTrace(java.lang.Exception e) throws java.lang.Exception
e
- The exception to print.java.lang.Exception
public java.lang.String getName()
public boolean initDaemon() throws java.lang.Exception
true
if the initialisation was successful,
otherwise false
.java.lang.Exception
enableEvents()
,
enableIncomingText()
,
postEvent(com.swath.UserDefinedEvent)
,
setTimer(java.util.Date)
,
printTrace(java.lang.String)
,
onTimer(java.util.Date)
,
onText(java.lang.String, java.lang.String)
,
onEvent(com.swath.EventIfc)
public void endDaemon() throws java.lang.Exception
java.lang.Exception
public void onTimer(java.util.Date time) throws java.lang.Exception
time
- The current time.java.lang.Exception
postEvent(com.swath.UserDefinedEvent)
,
setTimer(java.util.Date)
,
printTrace(java.lang.String)
public void onText(java.lang.String buffer, java.lang.String text) throws java.lang.Exception
setIncomingTextMode
to enable this callback method.skipBufferText
and setBufferText
methods.buffer
- The current text buffer.text
- The new incoming text.java.lang.Exception
enableIncomingText()
,
skipBufferText(int)
,
setBufferText(java.lang.String)
,
postEvent(com.swath.UserDefinedEvent)
,
setTimer(java.util.Date)
,
printTrace(java.lang.String)
public void onEvent(EventIfc event) throws java.lang.Exception
event
- The event.java.lang.Exception
enableEvents()
,
postEvent(com.swath.UserDefinedEvent)
,
setTimer(java.util.Date)
,
printTrace(java.lang.String)