Class ExampleDaemon1

java.lang.Object
  extended by com.swath.UserDefinedDaemon
      extended by ExampleDaemon1

public class ExampleDaemon1
extends UserDefinedDaemon

This is my first SWATH daemon. It demonstrates how to use the timer and how to receive events. Every 15 seconds it will display how many fighters the ship has.

Since:
SWATH 1.7

Constructor Summary
ExampleDaemon1()
           
 
Method Summary
 void endDaemon()
          Called by the framework when the daemon is shut down.
 java.lang.String getName()
          Called by the framework to get the name of the daemon.
 boolean initDaemon()
          Called by the framework to initialise the daemon.
 void onEvent(EventIfc event)
          This method is called for each posted event.
 void onText(java.lang.String buffer, java.lang.String text)
          This method is called when new text has arrived from the game server.
 void onTimer(java.util.Date time)
          This method is called when the timer is triggered.
 
Methods inherited from class com.swath.UserDefinedDaemon
enableEvents, enableIncomingText, getClassName, getResource, postEvent, printTrace, printTrace, setBufferText, setTimer, setTimer, skipBufferText
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExampleDaemon1

public ExampleDaemon1()
Method Detail

getName

public java.lang.String getName()
Description copied from class: UserDefinedDaemon
Called by the framework to get the name of the daemon.
You should override this method.

Overrides:
getName in class UserDefinedDaemon
Returns:
The daemon name.

initDaemon

public boolean initDaemon()
                   throws java.lang.Exception
Description copied from class: UserDefinedDaemon
Called by the framework to initialise the daemon.
You should override this method to make your own initialisation.

Overrides:
initDaemon in class UserDefinedDaemon
Returns:
true if the initialisation was successful, otherwise false.
Throws:
java.lang.Exception
See Also:
UserDefinedDaemon.enableEvents(), UserDefinedDaemon.enableIncomingText(), UserDefinedDaemon.postEvent(com.swath.UserDefinedEvent), UserDefinedDaemon.setTimer(java.util.Date), UserDefinedDaemon.printTrace(java.lang.String), UserDefinedDaemon.onTimer(java.util.Date), UserDefinedDaemon.onText(java.lang.String, java.lang.String), UserDefinedDaemon.onEvent(com.swath.EventIfc)

endDaemon

public void endDaemon()
               throws java.lang.Exception
Description copied from class: UserDefinedDaemon
Called by the framework when the daemon is shut down.
You can override this method to clean up after the daemon if needed.

Overrides:
endDaemon in class UserDefinedDaemon
Throws:
java.lang.Exception

onEvent

public void onEvent(EventIfc event)
             throws java.lang.Exception
Description copied from class: UserDefinedDaemon
This method is called for each posted event.
You can override this method to handle events.

Overrides:
onEvent in class UserDefinedDaemon
Parameters:
event - The event.
Throws:
java.lang.Exception
See Also:
UserDefinedDaemon.enableEvents(), UserDefinedDaemon.postEvent(com.swath.UserDefinedEvent), UserDefinedDaemon.setTimer(java.util.Date), UserDefinedDaemon.printTrace(java.lang.String)

onTimer

public void onTimer(java.util.Date time)
             throws java.lang.Exception
Description copied from class: UserDefinedDaemon
This method is called when the timer is triggered.

Overrides:
onTimer in class UserDefinedDaemon
Parameters:
time - The current time.
Throws:
java.lang.Exception
See Also:
UserDefinedDaemon.postEvent(com.swath.UserDefinedEvent), UserDefinedDaemon.setTimer(java.util.Date), UserDefinedDaemon.printTrace(java.lang.String)

onText

public void onText(java.lang.String buffer,
                   java.lang.String text)
            throws java.lang.Exception
Description copied from class: UserDefinedDaemon
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. You can use it when searching for information using the string helper methods. To remove text from the current buffer or reset its content, use the skipBufferText and setBufferText methods.

Overrides:
onText in class UserDefinedDaemon
Parameters:
buffer - The current text buffer.
text - The new incoming text.
Throws:
java.lang.Exception
See Also:
UserDefinedDaemon.enableIncomingText(), UserDefinedDaemon.skipBufferText(int), UserDefinedDaemon.setBufferText(java.lang.String), UserDefinedDaemon.postEvent(com.swath.UserDefinedEvent), UserDefinedDaemon.setTimer(java.util.Date), UserDefinedDaemon.printTrace(java.lang.String)