Class Session

java.lang.Object
convex.cli.peer.Session

public class Session extends Object
  • Field Details

  • Constructor Details

    • Session

      public Session()
  • Method Details

    • load

      public void load(File filename) throws IOException
      Load a session data from file.
      Parameters:
      filename - Filename of the session file to load.
      Throws:
      IOException
    • addPeer

      public void addPeer(AccountKey accountKey, String hostname, String etchFilename)
      Add a peer to the list of peers kept in the session data.
      Parameters:
      accountKey - Public key of Peer
      hostname - Hostname of the peer. This includes the port number.
      etchFilename - Filename that the peer is using to store the peer's state.
    • removePeer

      public void removePeer(AccountKey accountKey)
      Remove a peer from the list of peers held by this session.
      Parameters:
      accountKey - Address of the peer, this is the public key used by the peer.
    • store

      public void store(File filename) throws IOException
      Store the session list to a file.
      Parameters:
      filename - Filename to save the session too.
      Throws:
      IOException - if the file data cannot be writtern.
    • getSize

      public int getSize()
      Return the number of session items added to this session.
      Returns:
      number of items found for this session.
    • isPeer

      public boolean isPeer(AccountKey accountKey)
      Return true of false if the peer name exists in the list of peers for this session
      Parameters:
      accountKey - Public Key of the peer to check to see if it exists.
      Returns:
      true if the peer name exists, flase otherwise
    • getItemFromIndex

      public SessionItem getItemFromIndex(int index)
      Return a session item based on the peer index.
      Parameters:
      index - The index of the peer in the list, starting from 0.
      Returns:
      Session Item if the item is found at the index, if not then return null.
    • getItemFromAccountKey

      public SessionItem getItemFromAccountKey(AccountKey accountKey)
      Get a session item based on the peers AccountKey.
      Parameters:
      accountKey - AccountKey of the peer to get the session item for.
      Returns:
      SessionItem object or null if the peer account key cannot be found
    • getPeerHostnameList

      public String[] getPeerHostnameList()
      Get a list of peer hostnames.
      Returns:
      List hostname item for each stored peer.