|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeer2me.network.Network
peer2me.network.bluetooth.Bluetooth
public class Bluetooth
This class extends the Network
and every Bluetooth network operation is
controlled indirectly from this class. This class starts two listeners that are able to establish
incomming connections. It also have two queues that are used for outgoing messages and pings.
Constructor Summary | |
---|---|
Bluetooth()
Constructor that creates two empty queues for outgoing messages and pings |
Method Summary | |
---|---|
void |
activatePing()
Activates the ping functionality. |
void |
checkPingResponse(Node node)
Checks to see if nodes has responded to pings. |
void |
clean()
Stops the listeners from reveiving connections. |
void |
echo(Node node)
This method should run Node.incrementEcho() on the
given Node |
java.lang.String |
getLocalConnectionURL()
Returns the connectionURL of the local node |
java.lang.String |
getLocalPingConnectionURL()
Returns the connectionURL that must be used to ping the local node |
LinkedMessageList |
getMessageQue()
Returns the list that contains all messages that are to be sent |
LinkedPingRecipientsList |
getPingQue()
Returns the list that contains all pings that are to be sent |
void |
initialize()
Starts accepting incoming connections and starts the queue processors |
void |
messagePartReceived(java.lang.String messageID,
int part,
int total)
Every time when the BluetoothConnectionHandler receives a part of a message, it invokes
this method. |
void |
messageReceived(Message message)
When the BluetoothConnectionHandler receives a message, it reconstructs it and invokes
this method when the message is reconstructed. |
void |
nodeFound(NetworkNode networkNode)
When the BluetoothSearcher has found other nodes, it invokes this method. |
void |
nodeLost(Node node)
If a node leaves the network or does not respond to pings, this method is invoked. |
void |
ping()
This method puts all nodes in the pingQueue so that the PingQueueProcessor can process
the pings. |
boolean |
search()
Starts a search for other devices if there are no more messages in the queue. |
void |
searchCompleted()
Is invoked by BluetoothSearcher when a search has completed. |
void |
sendMessage(Message message)
Puts a message in the queue. |
void |
setActivatePing(boolean activatePing)
Sets a local variable determining if ping shall be used |
void |
setGoodbyeSent(boolean canILeaveNow)
To allow the node to exit, this method must be used |
void |
setLocalConnectionURL(java.lang.String localConnectionURL)
Sets the connectionURL of the local node |
void |
setLocalPingConnectionURL(java.lang.String localPingConnectionURL)
Sets the connectionURL that must be used to ping the local node |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Bluetooth()
Method Detail |
---|
public void initialize()
initialize
in class Network
public boolean search()
search
in class Network
public void echo(Node node)
Network
Node.incrementEcho()
on the
given Node
echo
in class Network
node
- the node that has respondedpublic void sendMessage(Message message)
MessageQueueProcessor
takes care of processing the message.
sendMessage
in class Network
message
- The message that is put in the queuepublic void messageReceived(Message message)
BluetoothConnectionHandler
receives a message, it reconstructs it and invokes
this method when the message is reconstructed. This method forwards the message to Session
.
messageReceived
in class Network
message
- public void messagePartReceived(java.lang.String messageID, int part, int total)
BluetoothConnectionHandler
receives a part of a message, it invokes
this method. This method forwards the part number and total parts to Session
.
part
- The part number that was receivedtotal
- Total number of parts in the messagepublic void nodeFound(NetworkNode networkNode)
BluetoothSearcher
has found other nodes, it invokes this method. The method is also
invoked if the BluetoothConnectionHandler
receives a message that contains information
about other nodes.
nodeFound
in class Network
networkNode
- the networkNode that is foundpublic void searchCompleted()
BluetoothSearcher
when a search has completed. No mather what the result of the
search was, this method will be called either way. This is so that the application knows when a
search is completed. A usual scenario might just be that no nodes where found.
searchCompleted
in class Network
public void nodeLost(Node node)
nodeLost
in class Network
node
- The node that is lostpublic void ping()
PingQueueProcessor
can process
the pings. This method is invoked at regular intervals by the NetworkTimer
.
ping
in class Network
public void checkPingResponse(Node node)
public void setActivatePing(boolean activatePing)
setActivatePing
in class Network
activatePing
- True if ping, false otherwisepublic void activatePing()
public void clean()
Framework.clean()
upon exit.
clean
in class Network
public java.lang.String getLocalConnectionURL()
public void setLocalConnectionURL(java.lang.String localConnectionURL)
localConnectionURL
- The connectionURL of the local nodepublic LinkedMessageList getMessageQue()
LinkedMessageList
public LinkedPingRecipientsList getPingQue()
LinkedPingRecipientsList
public java.lang.String getLocalPingConnectionURL()
public void setLocalPingConnectionURL(java.lang.String localPingConnectionURL)
localPingConnectionURL
- The URL that is set as the localPingConnectionURLpublic void setGoodbyeSent(boolean canILeaveNow)
canILeaveNow
- True if the node can exit, false otherwise
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |