net.tomp2p.connection
Class ConnectionHandler

java.lang.Object
  extended by net.tomp2p.connection.ConnectionHandler

public class ConnectionHandler
extends Object

Handles the server connections of a node, i.e. the connections a node is listening on.

Author:
Thomas Bocek

Field Summary
static String THREAD_NAME
           
static int UDP_LIMIT
           
 
Constructor Summary
ConnectionHandler(ConnectionHandler parent, Number160 id, KeyPair keyPair, PeerMap peerMap)
          Attaches a peer to an existing connection and use existing information
ConnectionHandler(int udpPort, int tcpPort, Number160 id, Bindings bindings, int p2pID, ConnectionConfiguration configuration, File messageLogger, KeyPair keyPair, PeerMap peerMap, List<PeerListener> listeners, P2PConfiguration peerConfiguration)
           
 
Method Summary
 void customLoggerMessage(String customMessage)
           
 ConnectionBean getConnectionBean()
           
 PeerBean getPeerBean()
          Returns the node information bean of this node
 boolean isListening()
           
 void mapUPNP(InetAddress internalAddress, int internalPortUDP, int internalPortTCP, InetAddress externalAddress, int externalPortUDP, int externalPortTCP)
          Adds a port forearding policy to UPNP enabled devices.
 void shutdown()
          Shuts down the dispatcher and frees resources
Note: does not close any channels, use shutdownSharedTCP or shutdownSharedUDP instead.
 boolean startupTCP(InetSocketAddress listenAddressesTCP, DispatcherRequest dispatcher, int maxMessageSize)
          Creates TCP channels and listens on them
 boolean startupUDP(InetSocketAddress listenAddressesUDP, DispatcherRequest dispatcher)
           
 void unmapUPNP()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UDP_LIMIT

public static final int UDP_LIMIT
See Also:
Constant Field Values

THREAD_NAME

public static final String THREAD_NAME
See Also:
Constant Field Values
Constructor Detail

ConnectionHandler

public ConnectionHandler(int udpPort,
                         int tcpPort,
                         Number160 id,
                         Bindings bindings,
                         int p2pID,
                         ConnectionConfiguration configuration,
                         File messageLogger,
                         KeyPair keyPair,
                         PeerMap peerMap,
                         List<PeerListener> listeners,
                         P2PConfiguration peerConfiguration)
                  throws Exception
Throws:
Exception

ConnectionHandler

public ConnectionHandler(ConnectionHandler parent,
                         Number160 id,
                         KeyPair keyPair,
                         PeerMap peerMap)
Attaches a peer to an existing connection and use existing information

Parameters:
parent -
id -
Method Detail

getConnectionBean

public ConnectionBean getConnectionBean()

startupUDP

public boolean startupUDP(InetSocketAddress listenAddressesUDP,
                          DispatcherRequest dispatcher)
                   throws Exception
Throws:
Exception

startupTCP

public boolean startupTCP(InetSocketAddress listenAddressesTCP,
                          DispatcherRequest dispatcher,
                          int maxMessageSize)
                   throws Exception
Creates TCP channels and listens on them

Parameters:
listenAddressesTCP - the addresses which we will listen on
Throws:
Exception

getPeerBean

public PeerBean getPeerBean()
Returns the node information bean of this node

Returns:

customLoggerMessage

public void customLoggerMessage(String customMessage)

shutdown

public void shutdown()
Shuts down the dispatcher and frees resources
Note: does not close any channels, use shutdownSharedTCP or shutdownSharedUDP instead.

Throws:
InterruptedException

unmapUPNP

public void unmapUPNP()

mapUPNP

public void mapUPNP(InetAddress internalAddress,
                    int internalPortUDP,
                    int internalPortTCP,
                    InetAddress externalAddress,
                    int externalPortUDP,
                    int externalPortTCP)
             throws IOException,
                    UPNPResponseException
Adds a port forearding policy to UPNP enabled devices. Internal is the peer, while external is the router

Parameters:
internalAddress -
internalPortUDP -
internalPortTCP -
externalAddress -
externalPortUDP -
externalPortTCP -
Throws:
IOException
UPNPResponseException

isListening

public boolean isListening()


Copyright © 2011. All Rights Reserved.