All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.www.sap.SapManager

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----w3c.www.sap.SapManager

public class SapManager
extends Thread
implements EventHandler
The SAP engine will both announce sessions, and handle declared sessions.


Variable Index

 o announces
List of announcements to make, keyed by session identifier.
 o DEFAULT_ADDRESS
SAP default multicast socket address.
 o DEFAULT_PORT
SAP default port number.
 o DELETE_ANNOUNCE_COUNTER
Number of deletion announcement to be sent by default.
 o DELETE_INTERVAL
Interval between deleion announcement:
 o eventManager
The event manager for handling announcements.
 o handler
The announce handler.
 o MIN_INTERVAL
Minimum announcement interval, in milliseconds.
 o port
Our port number.
 o SAP_VERSION
SAP version handled by this implementation.
 o socket
The SAP multicast socket.

Method Index

 o announce(Announce)
Make a session announcement.
 o createSession(String, long, long, String, String, InetAddress, String)
Create a blank session, to be filled out by the caller.
 o decode(byte[], int, int)
Decode a SAP packet.
 o delete(SapSession)
Delete, and announce deletion of a session.
 o enumerateSessions()
Enumerate all registered sessions.
 o getManager()
Get the default SAP manager for this application.
 o getManager(InetAddress, int)
Get a SAP manager for the given address/port pair.
 o handleTimerEvent(Object, long)
EventHandler implementation - An annouce is to be made right now.
 o main(String[])
 o run()
 o startAnnounce(SapSession, long)
Add the given session to the list of sessions to be announced.
 o stopAnnounce(SapSession)
Stop announcing the given session.
 o testingSession(SapManager)

Variables

 o DEFAULT_ADDRESS
 public static InetAddress DEFAULT_ADDRESS
SAP default multicast socket address.

 o DEFAULT_PORT
 public static final int DEFAULT_PORT
SAP default port number.

 o SAP_VERSION
 public static final int SAP_VERSION
SAP version handled by this implementation.

 o DELETE_INTERVAL
 public static final long DELETE_INTERVAL
Interval between deleion announcement:

 o DELETE_ANNOUNCE_COUNTER
 public static final int DELETE_ANNOUNCE_COUNTER
Number of deletion announcement to be sent by default.

 o MIN_INTERVAL
 public static final long MIN_INTERVAL
Minimum announcement interval, in milliseconds.

 o socket
 protected MulticastSocket socket
The SAP multicast socket.

 o port
 protected int port
Our port number.

 o announces
 protected Hashtable announces
List of announcements to make, keyed by session identifier.

 o eventManager
 protected EventManager eventManager
The event manager for handling announcements.

 o handler
 protected SapHandler handler
The announce handler.

Methods

 o decode
 protected SapSession decode(byte buf[],
                             int off,
                             int len)
Decode a SAP packet.

Parameters:
buf - The buffer containing the packet.
off - Offset of packet within above buffer.
len - Length of packet.
Returns:
A SapSession instance, or null if this was a Session Description Deletion.
 o getManager
 public static synchronized SapManager getManager() throws IOException
Get the default SAP manager for this application.

Returns:
A SapManager instance.
Throws: IOException
If the manager couldn't create the multicast socket to join the SAP channel.
 o getManager
 public static synchronized SapManager getManager(InetAddress a,
                                                  int p) throws IOException
Get a SAP manager for the given address/port pair. The same manager will be returned for the same pairs.

Parameters:
A - The SAP Inet address.
p - The SAP port.
Returns:
A SapManager instance.
Throws: IOException
If the manager couldn't create the multicast socket to join the SAP channel.
 o createSession
 public SapSession createSession(String username,
                                 long sid,
                                 long sversion,
                                 String snettype,
                                 String saddrtype,
                                 InetAddress saddr,
                                 String name)
Create a blank session, to be filled out by the caller.

Parameters:
username - Owner of the session.
sid - Session identifier.
sversion - Version of that session.
snettype - Session network type.
saddrtype - Session address type.
saddr - Session address.
name - Session name.
 o handleTimerEvent
 public void handleTimerEvent(Object data,
                              long time)
EventHandler implementation - An annouce is to be made right now.

Parameters:
data - The handler closure (a Announce instance).
time - Current time.
 o startAnnounce
 public void startAnnounce(SapSession s,
                           long interval)
Add the given session to the list of sessions to be announced.

Parameters:
s - The session to be announced.
interval - The interval between two announcements in milliseconds.
 o delete
 public void delete(SapSession s)
Delete, and announce deletion of a session.

Parameters:
s - The session description to announce deletion of.
 o stopAnnounce
 public void stopAnnounce(SapSession s)
Stop announcing the given session.

Parameters:
s - The session whose periodic announce is to stop.
 o enumerateSessions
 public Enumeration enumerateSessions()
Enumerate all registered sessions.

Returns:
A Enumeration of SapSession instances.
 o announce
 protected void announce(Announce a) throws IOException, UnknownHostException
Make a session announcement.

Parameters:
a - The announcement to be made.
 o run
 public void run()
Overrides:
run in class Thread
 o testingSession
 public static SapSession testingSession(SapManager engine) throws UnknownHostException
 o main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index