Package convex.cli.peer
Class Session
java.lang.Object
convex.cli.peer.Session
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPeer
(AccountKey accountKey, String hostname, String etchFilename) Add a peer to the list of peers kept in the session data.getItemFromAccountKey
(AccountKey accountKey) Get a session item based on the peers AccountKey.getItemFromIndex
(int index) Return a session item based on the peer index.String[]
Get a list of peer hostnames.int
getSize()
Return the number of session items added to this session.boolean
isPeer
(AccountKey accountKey) Return true of false if the peer name exists in the list of peers for this sessionvoid
Load a session data from file.void
removePeer
(AccountKey accountKey) Remove a peer from the list of peers held by this session.void
Store the session list to a file.
-
Field Details
-
items
-
-
Constructor Details
-
Session
public Session()
-
-
Method Details
-
load
Load a session data from file.- Parameters:
filename
- Filename of the session file to load.- Throws:
IOException
- If IO fails
-
addPeer
Add a peer to the list of peers kept in the session data.- Parameters:
accountKey
- Public key of Peerhostname
- Hostname of the peer. This includes the port number.etchFilename
- Filename that the peer is using to store the peer's state.
-
removePeer
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
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
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
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
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
Get a list of peer hostnames.- Returns:
- List
hostname item for each stored peer.
-