Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.wilko.jaim
Class JaimConnection  view JaimConnection download JaimConnection.java

java.lang.Object
  extended bycom.wilko.jaim.JaimConnection
All Implemented Interfaces:
java.lang.Runnable

public class JaimConnection
extends java.lang.Object
implements java.lang.Runnable

The JaimConnection object is the primary interface into the Jaim library. Programs should instantiate a JaimConnection (in most cases the simple constructor should be used). Once JaimConnection has been instantiated, call connect() 55 followed by logIn(java.lang.String, java.lang.String, int) 55 .

Version:
$Revision: 1.20 $

Nested Class Summary
private  class JaimConnection.DeliveryThread
           
private  class JaimConnection.ReceiverThread
           
 
Field Summary
private static int BLOCK_POINTS
           
private  java.util.HashMap buddies
           
private  int clientSequence
           
private  boolean configValid
           
private  boolean connected
           
private  boolean debug
           
private  JaimConnection.DeliveryThread dt
           
private  java.util.Vector eventListeners
           
private  boolean exit
           
private  java.util.HashMap groups
           
private  java.lang.String host
           
private  long lastKeepAlive
           
private  long lastMessageSendTime
           
private  boolean loggedIn
           
private  boolean loginComplete
           
private static int MAX_POINTS
           
private  java.util.Vector messageQueue
           
private  java.lang.Thread myThread
           
private  java.lang.String nickName
           
private static int POINT_RECOVERY_TIME
           
private  int port
           
private  JaimConnection.ReceiverThread rt
           
private  java.net.Socket s
           
private  int sendPoints
           
private  int serverSequence
           
private  java.io.InputStream sin
           
private  java.io.OutputStream sout
           
private static int THRESHOLD_DELAY
           
private static int WAIT_TIME
           
private  java.util.HashMap watchedBuddies
           
 
Constructor Summary
JaimConnection()
          Creates new JaimConnection that connects to the default host and port.
JaimConnection(java.lang.String host, int port)
          Creates a new Jaim Connection to the specified host/port.
 
Method Summary
 void addBlock(java.lang.String buddy)
          Adds the specified buddy to your block list.
 void addBuddy(java.lang.String buddy)
          Deprecated. the watchBuddy(java.lang.String) 55 method should be used instead
 Buddy addBuddy(java.lang.String buddyName, java.lang.String groupName)
          Add a buddy to a group.
 Buddy addBuddy(java.lang.String buddyName, java.lang.String groupName, int pos)
          Add a buddy to a group.
 void addEventListener(JaimEventListener l)
          Add an EventListener object.
 void addPermit(java.lang.String buddy)
          Adds the specified buddy to your permit list.
 void connect()
          Initiate a connection to the TOC server
private  void connectionLost()
          Called by receiver thread to indicate that the connection has been terminated by an IOException
 void deleteBuddy(java.lang.String buddy)
          Deprecated. use unwatchBuddy(java.lang.String) 55 instead
private  void deliverEvent(TocResponse tr)
          Deliver a TocResponse event to registered listeners
 void disconnect()
          Disconnect from the TOC server
protected  void Dispatch(FLAPFrame fr)
           
 Group getGroupBy(java.lang.String name)
          Return a group, given its name
 java.util.Collection getGroups()
          Return the set of groups that have been stored in the TOC server The information returned from this method is only valid if isConfigValid() 55 returns true
 void getInfo(java.lang.String username)
          Get the information for the specified user
 long getInterMessageDelay()
          Deprecated. This function is no longer used
 java.lang.String getNickName()
          Get the formatted Nick Name for this connection.
 java.io.InputStream getURL(java.lang.String file)
          Get an Input stream associated with a URL returned by the "GOTO_URL" toc response
protected  void HandleTocResponse(TocResponse tr)
           
 boolean isConfigValid()
          Indicate whether configuration information has been received from the TOC server.
 boolean isLoginComplete()
          Check if the TOC login process has completed
 void logIn(java.lang.String username, java.lang.String password, int waitTime)
          login to the TOC server.
 void logOut()
          Log out from the TOC server
private  int nextSequence()
           
private  void realDispatch(FLAPFrame fr)
           
 void removeEventListener(JaimEventListener l)
          Remove an EventListener object.
 void run()
          The run method for the dispatcher thread
 void saveConfig()
          Save group/buddy list configuration to the TOC server
 void sendEvil(java.lang.String buddy, boolean anonymous)
          Send a warning or "Evil" to another user.
 void sendIM(java.lang.String recipient, java.lang.String msg)
          Send an instant message
 void sendIM(java.lang.String recipient, java.lang.String msg, boolean auto)
          Send an instant message
private  void sendKeepAlive()
           
private  void sendTocCommand(TocCommand cmd)
           
 void setAway(java.lang.String awayMsg)
          Set the information for the logged in user
 void setDebug(boolean debug)
          Enable/Disable debugging messages to stdout
 void setEventListener(JaimEventListener l)
          Deprecated. replaced by addEventListener(com.wilko.jaim.JaimEventListener) 55
 void setIdle(int idleSecs)
          Set the idle time for this user
 void setInfo(java.lang.String information)
          Set the information for the logged in user
 void setInterMessageDelay(long msec)
          Deprecated. This function is no longer used - send throttling is automatic
private  void startMe()
          start the message dispatcher thread
 void unwatchBuddy(java.lang.String buddy)
          Delete a buddy from the buddy watch list.
 void watchBuddy(java.lang.String buddy)
          Add a buddy to the watch list for this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s

private java.net.Socket s

sin

private java.io.InputStream sin

sout

private java.io.OutputStream sout

connected

private boolean connected

loggedIn

private boolean loggedIn

loginComplete

private boolean loginComplete

configValid

private boolean configValid

host

private java.lang.String host

port

private int port

clientSequence

private int clientSequence

serverSequence

private int serverSequence

rt

private JaimConnection.ReceiverThread rt

dt

private JaimConnection.DeliveryThread dt

eventListeners

private java.util.Vector eventListeners

watchedBuddies

private java.util.HashMap watchedBuddies

buddies

private java.util.HashMap buddies

groups

private java.util.HashMap groups

nickName

private java.lang.String nickName

lastMessageSendTime

private long lastMessageSendTime

debug

private boolean debug

myThread

private java.lang.Thread myThread

messageQueue

private java.util.Vector messageQueue

exit

private boolean exit

lastKeepAlive

private long lastKeepAlive

sendPoints

private int sendPoints

MAX_POINTS

private static final int MAX_POINTS
See Also:
Constant Field Values

BLOCK_POINTS

private static final int BLOCK_POINTS
See Also:
Constant Field Values

POINT_RECOVERY_TIME

private static final int POINT_RECOVERY_TIME
See Also:
Constant Field Values

THRESHOLD_DELAY

private static final int THRESHOLD_DELAY
See Also:
Constant Field Values

WAIT_TIME

private static final int WAIT_TIME
See Also:
Constant Field Values
Constructor Detail

JaimConnection

public JaimConnection()
Creates new JaimConnection that connects to the default host and port. In most cases this constructor should be used.


JaimConnection

public JaimConnection(java.lang.String host,
                      int port)
Creates a new Jaim Connection to the specified host/port. There are currently no reasons to call this constructor, however AOL may change the TOC host and port in the future

Method Detail

startMe

private void startMe()
start the message dispatcher thread


setDebug

public void setDebug(boolean debug)
Enable/Disable debugging messages to stdout


setInterMessageDelay

public void setInterMessageDelay(long msec)
Deprecated. This function is no longer used - send throttling is automatic

Specify the intermessage delay time.
The sendIM(java.lang.String, java.lang.String) 55 method will ensure that at least this amount of time has elapsed between messages


getInterMessageDelay

public long getInterMessageDelay()
Deprecated. This function is no longer used

Get the intermessage delay time


setEventListener

public void setEventListener(JaimEventListener l)
                      throws java.util.TooManyListenersException
Deprecated. replaced by addEventListener(com.wilko.jaim.JaimEventListener) 55

Set the EventListener object. This object will be notified of incoming TOC events


addEventListener

public void addEventListener(JaimEventListener l)
Add an EventListener object. This object will be notified of incoming TOC events


removeEventListener

public void removeEventListener(JaimEventListener l)
Remove an EventListener object. This object will no longer be notified of incoming TOC events


connect

public void connect()
             throws java.io.IOException
Initiate a connection to the TOC server


disconnect

public void disconnect()
                throws java.io.IOException
Disconnect from the TOC server


isLoginComplete

public boolean isLoginComplete()
Check if the TOC login process has completed


logOut

public void logOut()
Log out from the TOC server


getNickName

public java.lang.String getNickName()
Get the formatted Nick Name for this connection. If no formatted nick name has been registered with the TOC server, then the username provided to the logIn call is returned


logIn

public void logIn(java.lang.String username,
                  java.lang.String password,
                  int waitTime)
           throws JaimException,
                  java.io.IOException
login to the TOC server. connect() 55 method should be called first


sendTocCommand

private void sendTocCommand(TocCommand cmd)
                     throws java.io.IOException

nextSequence

private int nextSequence()

sendKeepAlive

private void sendKeepAlive()
                    throws java.io.IOException

run

public void run()
The run method for the dispatcher thread

Specified by:
run in interface java.lang.Runnable

Dispatch

protected void Dispatch(FLAPFrame fr)

realDispatch

private void realDispatch(FLAPFrame fr)

HandleTocResponse

protected void HandleTocResponse(TocResponse tr)

deliverEvent

private void deliverEvent(TocResponse tr)
Deliver a TocResponse event to registered listeners


sendIM

public void sendIM(java.lang.String recipient,
                   java.lang.String msg)
            throws java.io.IOException
Send an instant message


sendIM

public void sendIM(java.lang.String recipient,
                   java.lang.String msg,
                   boolean auto)
            throws java.io.IOException
Send an instant message


addBuddy

public Buddy addBuddy(java.lang.String buddyName,
                      java.lang.String groupName,
                      int pos)
Add a buddy to a group. This information can be saved on the server by calling saveConfig() 55


addBuddy

public Buddy addBuddy(java.lang.String buddyName,
                      java.lang.String groupName)
Add a buddy to a group. This information can be saved on the server by calling saveConfig() 55 The buddy is added to the end of the group


addBuddy

public void addBuddy(java.lang.String buddy)
              throws JaimException
Deprecated. the watchBuddy(java.lang.String) 55 method should be used instead

Add a buddy to the watch list for this connection. This method must be called after connect() 55 It also appears that the login process will not complete unless at least one buddy is added to the watch list


watchBuddy

public void watchBuddy(java.lang.String buddy)
                throws JaimException
Add a buddy to the watch list for this connection. This method must be called after connect() 55 It also appears that the login process will not complete unless at least one buddy is added to the watch list


saveConfig

public void saveConfig()
                throws java.io.IOException
Save group/buddy list configuration to the TOC server


getGroups

public java.util.Collection getGroups()
Return the set of groups that have been stored in the TOC server The information returned from this method is only valid if isConfigValid() 55 returns true


getGroupBy

public Group getGroupBy(java.lang.String name)
Return a group, given its name


isConfigValid

public boolean isConfigValid()
Indicate whether configuration information has been received from the TOC server. If this method returns true then the information returned by getGroups() 55 is valid


sendEvil

public void sendEvil(java.lang.String buddy,
                     boolean anonymous)
              throws java.io.IOException
Send a warning or "Evil" to another user. You must be involved in a communication with a user before you can warn them


setInfo

public void setInfo(java.lang.String information)
             throws java.io.IOException
Set the information for the logged in user


getInfo

public void getInfo(java.lang.String username)
             throws java.io.IOException
Get the information for the specified user


getURL

public java.io.InputStream getURL(java.lang.String file)
                           throws java.io.IOException,
                                  java.net.MalformedURLException
Get an Input stream associated with a URL returned by the "GOTO_URL" toc response


setAway

public void setAway(java.lang.String awayMsg)
             throws java.io.IOException
Set the information for the logged in user


addPermit

public void addPermit(java.lang.String buddy)
               throws JaimException
Adds the specified buddy to your permit list.


addBlock

public void addBlock(java.lang.String buddy)
              throws JaimException
Adds the specified buddy to your block list.


connectionLost

private void connectionLost()
Called by receiver thread to indicate that the connection has been terminated by an IOException


setIdle

public void setIdle(int idleSecs)
             throws java.io.IOException
Set the idle time for this user


deleteBuddy

public void deleteBuddy(java.lang.String buddy)
Deprecated. use unwatchBuddy(java.lang.String) 55 instead

Delete a buddy from the buddy watch list. The buddy should have been added with addBuddy(java.lang.String, java.lang.String, int) 55 first. The buddy list can only be modified after connect() 55 is called.


unwatchBuddy

public void unwatchBuddy(java.lang.String buddy)
Delete a buddy from the buddy watch list. The buddy should have been added with addBuddy(java.lang.String, java.lang.String, int) 55 first. The buddy list can only be modified after connect() 55 is called.