commLibs
Class AIMLib

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--commLibs.AIMLib
All Implemented Interfaces:
JavaTOC.Chatable, CommLib, Runnable

public class AIMLib
extends Thread
implements CommLib, JavaTOC.Chatable

AIMLib implements the AOL Instant Messanger protocal within the specification of the CommLib interface. This class relies on a repackaged version of the JavaTOC library written by Jeff Heaton ( http://www.jeffheaton.com).

Author:
Ryan Michela

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AIMLib()
           
 
Method Summary
 void bindCallback(CommLibCallback callback)
          Provodes callback binding.
 boolean connect(String loggin, String password)
          Establishes a connection with the TOC server and attempts to start the dispatch thread.
protected  String dehtmlify(String input)
          Strips input of all HTML tags.
 void disconnect()
          Disconnects from the TOC network.
 void doPing()
          Called by the connection port maintnance thread.
protected  String err(int num)
          Converts a TOC error code into a TOC error string.
 void error(String str, String var)
          Handles incomming errors from the TOC library.
 String getWarningLevel()
          Gets the warning level.
 String identifyProtocal()
          Identifies the protocal this library implements.
 void im(String from, String message)
          Forewards an incomming IM throught the callback chain.
 void run()
          TOC Dispatch thread.
 void sendMessage(IM message)
          Sends a message.
 void sendWarning(String screenName, boolean anonymous)
          Sends a warning.
 void unknown(String str)
          Handles incomming unknown TOC events.
 
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, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AIMLib

public AIMLib()
Method Detail

bindCallback

public void bindCallback(CommLibCallback callback)
Provodes callback binding.

Specified by:
bindCallback in interface CommLib
Parameters:
callback - The callback object to bind to.
See Also:
CommLib.bindCallback(org.nukesoft.bot2.commlib.CommLibCallback)

connect

public boolean connect(String loggin,
                       String password)
Establishes a connection with the TOC server and attempts to start the dispatch thread.

Specified by:
connect in interface CommLib
Parameters:
loggin - The screen name to connect to.
password - The password to use.
Returns:
TRUE if successfull. FALSE if not.
See Also:
CommLib.connect(java.lang.String, java.lang.String)

disconnect

public void disconnect()
Disconnects from the TOC network.

Specified by:
disconnect in interface CommLib
See Also:
CommLib.disconnect()

sendMessage

public void sendMessage(IM message)
Sends a message.

Specified by:
sendMessage in interface CommLib
Parameters:
message - The message to send.
See Also:
CommLib.sendMessage(org.nukesoft.bot2.core.IM)

sendWarning

public void sendWarning(String screenName,
                        boolean anonymous)
Sends a warning.

Specified by:
sendWarning in interface CommLib
Parameters:
screenName - The screen name to warn.
anonymous - Warn anonymously if true.
See Also:
CommLib.sendWarning(java.lang.String, boolean)

identifyProtocal

public String identifyProtocal()
Identifies the protocal this library implements.

Specified by:
identifyProtocal in interface CommLib
Returns:
The protocal string.
See Also:
CommLib.identifyProtocal()

doPing

public void doPing()
Called by the connection port maintnance thread. Attempts to send a self addressed message. If the message does not return in three seconds, the connection is closed and reopened.

Specified by:
doPing in interface CommLib
See Also:
CommLib.doPing()

error

public void error(String str,
                  String var)
Handles incomming errors from the TOC library.

Specified by:
error in interface JavaTOC.Chatable
Parameters:
str - The ID of the error.
var - Not sure.
See Also:
Chatable.error(java.lang.String, java.lang.String)

im

public void im(String from,
               String message)
Forewards an incomming IM throught the callback chain.

Specified by:
im in interface JavaTOC.Chatable
See Also:
Chatable.im(java.lang.String, java.lang.String)

unknown

public void unknown(String str)
Handles incomming unknown TOC events.

Specified by:
unknown in interface JavaTOC.Chatable
See Also:
Chatable.unknown(java.lang.String)

getWarningLevel

public String getWarningLevel()
Gets the warning level.

Specified by:
getWarningLevel in interface CommLib
Returns:
"###" if warning level supported, "N/A" if not.
See Also:
CommLib.getWarningLevel()

run

public void run()
TOC Dispatch thread.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Runnable.run()

dehtmlify

protected String dehtmlify(String input)
Strips input of all HTML tags.

Parameters:
input - Text with embeded HTML.
Returns:
Text without any HTML.

err

protected String err(int num)
Converts a TOC error code into a TOC error string.

Parameters:
num - Error code.
Returns:
Error description.