network
Class IPCache

java.lang.Object
  extended bynetwork.IPCache

public class IPCache
extends java.lang.Object

Author:
hoele, cooperse A list of IP addresses used for finding neighbors. Whenever you remove a neighbor, add its IP to this list.

Field Summary
static java.lang.String IP_CACHE_FILENAME
          file name of local cache of IPs of other users
static java.lang.String SERVER_CACHE_FILENAME
          file name of local cache of IPs of cache servers.
 
Constructor Summary
IPCache(Network network, int maxSize)
          Creates a new IPCache.
 
Method Summary
 void addAddress(java.lang.String address)
          Add an address to the IPCache.
 void reloadServers()
          Add servers to cache list again, in case they were replaced during session and we then we lose all connections and need them again.
 java.lang.String removeAddress()
          Removes an address from the IPCache.
 void save()
          Save the IPCache to a local file.
 void save(java.io.File out)
          Saves the IPCache to the given file.
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IP_CACHE_FILENAME

public static final java.lang.String IP_CACHE_FILENAME
file name of local cache of IPs of other users

See Also:
Constant Field Values

SERVER_CACHE_FILENAME

public static final java.lang.String SERVER_CACHE_FILENAME
file name of local cache of IPs of cache servers. Unlike above, this file doesn't get overwritten so your server ips stay in tact.

See Also:
Constant Field Values
Constructor Detail

IPCache

public IPCache(Network network,
               int maxSize)
Creates a new IPCache.

Parameters:
network - The network the IPCache is for.
maxSize - The maximum number of IPs in the IPCache.
Method Detail

reloadServers

public void reloadServers()
Add servers to cache list again, in case they were replaced during session and we then we lose all connections and need them again.


save

public void save()
Save the IPCache to a local file.


save

public void save(java.io.File out)
Saves the IPCache to the given file.

Parameters:
out - The name of the local file in which to save the ipCache

removeAddress

public java.lang.String removeAddress()
Removes an address from the IPCache.

Returns:
An address from the IPCache or null if none exist.

addAddress

public void addAddress(java.lang.String address)
Add an address to the IPCache.

Parameters:
address - The address to add.

size

public int size()