Class ServerFramework


The ServerFramework is the core class for the server side of the P2P Application Framework. The ServerFramework provides a number of utility methods that can be accessed by plugins. In later versions of the framework the functionality of the ServerFramework may be increased

 
Method Summary
 java.lang.Object BytesToObject(byte[] data)
           
 java.util.HashMap GetMediaTypes()
           
 java.lang.String GetPeerAdvert(int ID)
           
 java.lang.String GetPluginsPath()
           
 void InsertTextToTextArea(java.lang.String text)
           
 byte[] ObjectToBytes(java.lang.Object o)
           
 java.lang.String ObjectToString(java.lang.Object o)
           
 boolean SendMessage(java.lang.String targetid, java.util.HashMap messageparts, java.awt.Component listener)
           
 java.lang.Object StringToObject(java.lang.String s)
           
Method Detail

GetMediaTypes

public java.util.HashMap GetMediaTypes()

This method returns a HashMap containing instances of all the MediaTypes that exist within the system. The the MediaType's ID's are used as Keys for the HashMap.


ObjectToString

public java.lang.String ObjectToString(java.lang.Object o)

This utility method allows plugins to convert an Object to a String. Created Strings are Base64 encoded so they can be sent as part of a message.

o - Object that is to be converted


StringToObject

public java.lang.Object StringToObject(java.lang.String s)

This utility method allows plugins to convert a String back to an Object.

s - the String that is to be converted.


InsertTextToTextArea

public void InsertTextToTextArea(java.lang.String text)

This method inserts text into the status area (TextArea) of the Server front-end

text - the text that is to be inserted


GetPluginsPath

public java.lang.String GetPluginsPath()

This method returns the path location of the Plugins directory within the ServerFramework. Currently the returned path is only a relative path.


GetPipeAdvert

public java.lang.String GetPipeAdvert(int ID)

This method returns the Pipe Advert for the specified user (that satisfies the provided parameters).

ID - the unique ID of the user


SendMessage

public boolean SendMessage(java.lang.String targetid,
                           java.util.HashMap messageparts,
                           java.awt.Component listener)

This method is used by plugins to send messages through the network. When the framework receives a message for a plugin the MessageArrived() method within that plugin is called.

targetid - the ID of the target user/peer
messageparts - a HashMap that contains the message elements
listener - not currently used


ObjectToBytes

public byte[] ObjectToBytes(java.lang.Object o)

This utility method converts a provided Object into a byte array. This can be useful for storing data within certain types of database (for example, MySQL).

o - the Object that is to be converted


BytesToObject

public java.lang.Object BytesToObject(byte[] data)

This utility method converts a provided byte array into an Object.

data - the byte array that is to be converted