org.nukesoft.commlib
Class CommPort

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.nukesoft.commlib.CommPort
All Implemented Interfaces:
CommLibCallback, Runnable

public class CommPort
extends Thread
implements CommLibCallback

The CommPort class wraps an externaly loaded CommLib and handles such tasks as connection maintnance and error correction.

Author:
Ryan Michela

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CommPort(String loggin, String password, String libPath, int pingDelay, CommPortCallback callback, String bindName)
           
 
Method Summary
 String getBindName()
          Gets the Bind Name for theis CommPort.
 String getWarningLevel()
          Returns the CommLib warning level.
 void handleError(String error)
          Handles in incomming error.
 void handleIM(IM message)
          Handles an incomming instant message.
 void handleWarn(String screenName)
          Handles incomming warnings.
 void run()
          Main loop for the connection maintnance thread.
 void sendMessage(IM message)
          Sends an instant message over the network.
 void sendWarning(String screenName, boolean anonymous)
          Attempts to warn an individual.
 void shutdown()
          Shuts down the CommPort and disconnects from the IM network.
 
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

CommPort

public CommPort(String loggin,
                String password,
                String libPath,
                int pingDelay,
                CommPortCallback callback,
                String bindName)
Parameters:
loggin - The loggin for this port to use.
password - The associated password.
libPath - The path to the communications library to load.
pingDelay - The number of seconds between pings. Zero for infinite.
callback - Class implementing the CommPortCallback interface used to receive incomming message events.
bindName - The bind name of this CommPort
Method Detail

shutdown

public void shutdown()
Shuts down the CommPort and disconnects from the IM network.


sendMessage

public void sendMessage(IM message)
Sends an instant message over the network.

Parameters:
message - The message to send.

sendWarning

public void sendWarning(String screenName,
                        boolean anonymous)
Attempts to warn an individual. May not have an effect on all networks.

Parameters:
screenName - The target.
anonymous - If true, attempt to warn anonymously.

handleError

public void handleError(String error)
Handles in incomming error.

Specified by:
handleError in interface CommLibCallback
See Also:
CommLibCallback.handleError(java.lang.String)

handleIM

public void handleIM(IM message)
Handles an incomming instant message.

Specified by:
handleIM in interface CommLibCallback
Parameters:
message -
See Also:
CommLibCallback.handleIM(org.nukesoft.core.IM)

handleWarn

public void handleWarn(String screenName)
Handles incomming warnings.

Specified by:
handleWarn in interface CommLibCallback
Parameters:
screenName - The screen name that did the warning.
See Also:
CommLibCallback.handleWarn(java.lang.String)

getWarningLevel

public String getWarningLevel()
Returns the CommLib warning level.

Returns:
Warning level.
See Also:
getWarningLevel()

getBindName

public String getBindName()
Gets the Bind Name for theis CommPort.

Returns:
The bind name.

run

public void run()
Main loop for the connection maintnance thread. Pings the connection and waits for a response.

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