jerklib
Class ConnectionManager

java.lang.Object
  extended by jerklib.ConnectionManager

public class ConnectionManager
extends Object

This class is used to control/store Sessions/Connections. Request new connections with this class.

Author:
mohadib

Constructor Summary
ConnectionManager(Profile defaultProfile)
          Takes a profile to use as default profile for new Connections
 
Method Summary
 void addWriteRequestListener(WriteRequestListener listener)
          Adds a listener to be notified of all writes
 IRCEventListener getDefaultEventHandler()
          Gets the InternalEventHandler to use for this Session.
 InternalEventParser getDefaultInternalEventParser()
          Get the InternalEventParser used for this Session.
 Profile getDefaultProfile()
          gets the default profile used for new connections
 Session getSession(String name)
          gets a session by name
 List<Session> getSessions()
          get a list of Sessions
 List<WriteRequestListener> getWriteListeners()
          gets an unmodifiable list of WriteListeners
 void quit()
          Closes all Sessions and exits library
 void quit(String quitMsg)
          Closes all connections and shuts down manager
 Session requestConnection(String hostName)
          request a new connection to a host with the default port of 6667
 Session requestConnection(String hostName, int port)
          request a new connection to a host
 Session requestConnection(String hostName, int port, Profile profile)
          request a new connection to a host
 void setDefaultInternalEventHandler(IRCEventListener handler)
          Sets the InternalEventHandler to use for this Session.
 void setDefaultInternalEventParser(InternalEventParser parser)
          Set the InternalEventParser used for this Session.
 void setDefaultProfile(Profile profile)
          sets the default profile to use for new connections
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManager

public ConnectionManager(Profile defaultProfile)
Takes a profile to use as default profile for new Connections

Parameters:
defaultProfile - default user profile
See Also:
Profile
Method Detail

getSessions

public List<Session> getSessions()
get a list of Sessions

Returns:
Session list

getSession

public Session getSession(String name)
gets a session by name

Parameters:
name - session name - the hostname of the server this session is for
Returns:
Session or null if no Session with name exists

addWriteRequestListener

public void addWriteRequestListener(WriteRequestListener listener)
Adds a listener to be notified of all writes

Parameters:
listener - to be notified

getWriteListeners

public List<WriteRequestListener> getWriteListeners()
gets an unmodifiable list of WriteListeners

Returns:
listeners

requestConnection

public Session requestConnection(String hostName)
request a new connection to a host with the default port of 6667

Parameters:
hostName - DNS name or IP of host to connect to
Returns:
the Session for this connection

requestConnection

public Session requestConnection(String hostName,
                                 int port)
request a new connection to a host

Parameters:
hostName - DNS name or IP of host to connect to
port - port to use for connection
Returns:
the Session for this connection

requestConnection

public Session requestConnection(String hostName,
                                 int port,
                                 Profile profile)
request a new connection to a host

Parameters:
hostName - DNS name or IP of host to connect to
port - port to use for connection
profile - profile to use for this connection
Returns:
the Session for this connection

quit

public void quit(String quitMsg)
Closes all connections and shuts down manager

Parameters:
quitMsg - quit message

quit

public void quit()
Closes all Sessions and exits library


getDefaultProfile

public Profile getDefaultProfile()
gets the default profile used for new connections

Returns:
default profile

setDefaultProfile

public void setDefaultProfile(Profile profile)
sets the default profile to use for new connections

Parameters:
profile - default profile to use for connections

setDefaultInternalEventHandler

public void setDefaultInternalEventHandler(IRCEventListener handler)
Sets the InternalEventHandler to use for this Session.

Parameters:
handler -

getDefaultEventHandler

public IRCEventListener getDefaultEventHandler()
Gets the InternalEventHandler to use for this Session.

Returns:
default Event Handler

setDefaultInternalEventParser

public void setDefaultInternalEventParser(InternalEventParser parser)
Set the InternalEventParser used for this Session.

Parameters:
parser -

getDefaultInternalEventParser

public InternalEventParser getDefaultInternalEventParser()
Get the InternalEventParser used for this Session.

Returns:
InternalEventParser for Session