peer2me.network
Class Network

java.lang.Object
  extended by peer2me.network.Network
Direct Known Subclasses:
Bluetooth

public abstract class Network
extends java.lang.Object

This is an abstract class representing the network used for communication. Should be extended by the class representing networktechnology. I.e. Bluetooth extends this class.

Author:
Tommy Bjoernsgaard

Constructor Summary
Network()
          Default empty constructor
 
Method Summary
abstract  void clean()
          This method should clean up the framework, closing active connections etc.
abstract  void echo(Node node)
          This method should run Node.incrementEcho() on the given Node
abstract  void initialize()
          This method should initialize the framework making it discoverable and ready to perform a search
abstract  void messageReceived(Message message)
          This method should be called whenever a Message is received
abstract  void nodeFound(NetworkNode networkNode)
          This method should be called whenever a new node is found.
abstract  void nodeLost(Node node)
          This method should be called whenever a node is lost or abscent.
abstract  void ping()
          This method is needed by NetworkTimer to alert whenever a ping should run
abstract  boolean search()
          This method should perform a search for services and devices
abstract  void searchCompleted()
          This method should be called wheneve a search is finished.
abstract  void sendMessage(Message message)
          This method should send a Message to another Node
abstract  void setActivatePing(boolean activeatePing)
          This method sets if the ping-functionality should be used or not
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Network

public Network()
Default empty constructor

Method Detail

initialize

public abstract void initialize()
This method should initialize the framework making it discoverable and ready to perform a search


search

public abstract boolean search()
This method should perform a search for services and devices

Returns:
true if a search can be performed, false if it is not possible

sendMessage

public abstract void sendMessage(Message message)
This method should send a Message to another Node

Parameters:
message - the Message to send

setActivatePing

public abstract void setActivatePing(boolean activeatePing)
This method sets if the ping-functionality should be used or not

Parameters:
activeatePing - true if the ping should be used, else false

nodeFound

public abstract void nodeFound(NetworkNode networkNode)
This method should be called whenever a new node is found.

Parameters:
networkNode - the networkNode that is found

nodeLost

public abstract void nodeLost(Node node)
This method should be called whenever a node is lost or abscent.

Parameters:
node - the node that is lost.

messageReceived

public abstract void messageReceived(Message message)
This method should be called whenever a Message is received

Parameters:
message - the message that is received

ping

public abstract void ping()
This method is needed by NetworkTimer to alert whenever a ping should run


echo

public abstract void echo(Node node)
This method should run Node.incrementEcho() on the given Node

Parameters:
node - the node that has responded

clean

public abstract void clean()
This method should clean up the framework, closing active connections etc. Is intended to be used when exiting the framework/application


searchCompleted

public abstract void searchCompleted()
This method should be called wheneve a search is finished.