com.kenmccrary.jtella
Class NetworkConnection

java.lang.Object
  |
  +--com.kenmccrary.jtella.NetworkConnection

public class NetworkConnection
extends java.lang.Object
implements java.lang.Runnable

The NetworkConnection represents a connection to the GNUTella network. The connection consists of one or more socket connections to servants on the network.

The following is an example initiating a NetworkConnection.

     NetworkConnection c = new NetworkConnection(host, port);
     c.addConnectionListener(new ConnectionListenerImpl());
     c.start();
 


Constructor Summary
NetworkConnection(java.lang.String host, int port)
          Construct the Connection;
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
          Adds a listener interested in connection information
 SearchSession createSearchSession(MessageReceiver receiver)
          Creates a session to conduct network searches
 SearchMonitorSession getSearchMonitorSession(MessageReceiver searchReceiver)
          Get a search monitor session to monitor query requests flowing through this network connection, at this time only one SearchMonitorSession at a time is supported
 boolean isOnline()
          Query if we are online with the network
 void removeConnectionListener(ConnectionListener listener)
          Removes a listener interested in connection information
 void run()
          Run the connection thread
 void start()
          Starts the connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkConnection

public NetworkConnection(java.lang.String host,
                         int port)
                  throws java.net.UnknownHostException,
                         java.io.IOException
Construct the Connection;
Parameters:
host - can be a machine name or IP address
port - port to use
Method Detail

start

public void start()
Starts the connection

isOnline

public boolean isOnline()
Query if we are online with the network
Returns:
true if online, false otherwise

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Adds a listener interested in connection information
Parameters:
listener - connection listener

removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
Removes a listener interested in connection information
Parameters:
listener - connection listener

createSearchSession

public SearchSession createSearchSession(MessageReceiver receiver)
Creates a session to conduct network searches
Parameters:
receiver - receiver for search responses
Returns:
session

getSearchMonitorSession

public SearchMonitorSession getSearchMonitorSession(MessageReceiver searchReceiver)
Get a search monitor session to monitor query requests flowing through this network connection, at this time only one SearchMonitorSession at a time is supported
Parameters:
searchReceiver - message receiver

run

public void run()
Run the connection thread
Specified by:
run in interface java.lang.Runnable