peer2me.framework
Interface Framework

All Known Implementing Classes:
FrameworkFrontEnd

public interface Framework

This interface acts as a "facade" for the entire Peer2Me framework as the methods in this interface is the only methods the MIDlets running the framework needs access to. To use the Peer2Me framework, the MIDlets should run the FrameworkFrontEnd.getInstance() which returns a reference of type Framework. All framework services is then available through this reference.

Author:
Torbjørn Vatn & Steinar A. Hestnes

Method Summary
 void connectToNodes(java.lang.String[] addresses)
          This method connects multiple devices in a network.
 java.util.Enumeration getFileList(java.lang.String root)
          This method returns a list of the files in the given root directory on the device
 void initFramework(java.lang.String nodeName, java.lang.String midletName, java.lang.String preferredNetwork)
          This method initiates the framework, and is the first method that should be run after getting a instance of the framework.
 void sendFilePackage(java.lang.String[] recipients, java.lang.String filePath)
          This method sends a file package over the network.
 void sendTextPackage(java.lang.String[] recipients, java.lang.String textMessage)
          This method sends a text package over the network.
 void shutdownFramework()
          This method shuts down the framework and closes all the open network connections and streams.
 void startNodeSearch()
          This method starts a search for devices running the same MIDlet.
 

Method Detail

initFramework

public void initFramework(java.lang.String nodeName,
                          java.lang.String midletName,
                          java.lang.String preferredNetwork)
                   throws java.lang.ClassNotFoundException,
                          java.lang.IllegalAccessException,
                          java.lang.InstantiationException,
                          java.io.IOException,
                          java.lang.Exception
This method initiates the framework, and is the first method that should be run after getting a instance of the framework. It initiates the fundamental services offered by the framework.

Parameters:
nodeName - The name of the user of the MIDlet.
midletName - The name of the MIDlet, eventually translated into a ServiceID used to find other devices running the same MIDlet.
preferredNetwork - Deciding which network implementation to use.
Throws:
java.lang.ClassNotFoundException - The input preferredNetwork is invalid
java.lang.IllegalAccessException - The input preferredNetwork is invalid
java.lang.InstantiationException - The input preferredNetwork is invalid
java.io.IOException - Error initiating framework
java.lang.Exception - Error initiating framework

shutdownFramework

public void shutdownFramework()
This method shuts down the framework and closes all the open network connections and streams. It should be called before closing the MIDlet to clean up the network connections.


startNodeSearch

public void startNodeSearch()
                     throws java.io.IOException
This method starts a search for devices running the same MIDlet. When such a device is found, the notifyAboutFoundNode() method specified by the FrameworkListener interface is called.

Throws:
java.io.IOException - Thrown if the search crashes

connectToNodes

public void connectToNodes(java.lang.String[] addresses)
This method connects multiple devices in a network. When a connection is established, the notifyAboutParticipants() method specified by the FrameworkListener interface is called.

Parameters:
addresses - The addresses of the devices to connect to.

sendTextPackage

public void sendTextPackage(java.lang.String[] recipients,
                            java.lang.String textMessage)
This method sends a text package over the network. When the package terminates to the recipients, they are alerted by the notifyAboutReceivedTextPackage() method specified by the FrameworkListener interface.

Parameters:
recipients - A list containing the addresses of the recipient nodes
textMessage - The text message to be sent

sendFilePackage

public void sendFilePackage(java.lang.String[] recipients,
                            java.lang.String filePath)
This method sends a file package over the network. When the package terminates to the recipients, they are alerted by the notifyAboutReceivedFilePackage() method specified by the FrameworkListener interface.

Parameters:
recipients - A list containing the addresses of the recipient nodes
filePath - The path of the file to be sent

getFileList

public java.util.Enumeration getFileList(java.lang.String root)
This method returns a list of the files in the given root directory on the device

Parameters:
root - The path to the root directory
Returns:
An enumeration containing the names of the files in the root directory