-
Notifications
You must be signed in to change notification settings - Fork 0
Resident App
BadSyncDirectory
DeviceNotFound
The class responsible for the communication between two devices which is established by sending actions: fetch, sync and delete.
Class Summary
Constructor
public ConnectivityResident(int port, Path directory) throws BadSyncDirectory, PortUnreachableException, SocketExceptionMethods
- Summary
public void setDirectory(Path directory) throws BadSyncDirectory
public void setPort(int port) throws PortUnreachableException, SocketException
private void actionFiles(int index, TreeActionsEnum action, Path... subPath) throws DeviceNotFound, IOException
public void fetchFiles(int index, Path... subPath) throws DeviceNotFound, IOException
public void syncFiles(int index, Path... subPath) throws DeviceNotFound, IOException
public void deleteFiles(int index, Path... subPath) throws DeviceNotFound, IOException
public List<Device> findNewDevices() throws BroadcastFailedException
public List<Device> getConnectedDevices()
public void connectTo(int index) throws DeviceNotFound, DeviceAlreadyConnectedException, IOException- Details
1. public void setDirectory(Path directory) throws BadSyncDirectory
This method is used to set the direcorty that will store and receive the files the user wishes to syncronize between devices.
Parameters:
- directory -> The path for the directory used to store the files destined to be syncronized.
Throws:
- BadSyncDirectory -> Inaccesible directory.
2. public void setPort(int port) throws PortUnreachableException, SocketException
This method is used to set the port for the connection.
Parameters:
- port -> The port given for establishing the connection.
Throws:
- PortUnreachableException -> The port is not available for connection.
- SocketException -> Standard socket exception.
3. private void actionFiles(int index, TreeActionsEnum action, Path... subPath) throws DeviceNotFound, IOException
This method is used to send an action request to a specified device.
Parameters:
- index -> The position where the desired device is found in the list of last searched connected devices.
- action -> The type of action to be send.
- subPath -> The path to specific files.
Throws:
- DeviceNotFound -> The device at the given index was not found.
- IOException
4. public void fetchFiles(int index, Path... subPath) throws DeviceNotFound, IOException
This method is used to invoke the method that will send the fetch action.
Parameters:
- index -> The position where the desired device is found in the list of last searched connected devices.
- subPath -> The path to specific files.
Throws:
- DeviceNotFound -> The device at the given index was not found.
- IOException
5. public void syncFiles(int index, Path... subPath) throws DeviceNotFound, IOException
This method is used to invoke the method that will send the sync action.
Parameters:
- index -> The position where the desired device is found in the list of last searched connected devices.
- subPath -> The path to specific files.
Throws:
- DeviceNotFound -> The device at the given index was not found.
- IOException
6. public void deleteFiles(int index, Path... subPath) throws DeviceNotFound, IOException
This method is used to invoke the method that will send the delete action.
Parameters:
- index -> The position where the desired device is found in the list of last searched connected devices.
- subPath -> The path to specific files.
Throws:
- DeviceNotFound -> The device at the given index was not found.
- IOException
7. public List findNewDevices() throws BroadcastFailedException
This method is used to obtain a list of recently connected devices.
Returns:
- The list of connected devices.
Throws:
- BroadcastFailedException -> Could not get information through the connection.
8. public List getConnectedDevices()
This method is used when the list of connected devices is needed.
Returns:
- The list of connected devices.
9. public void connectTo(int index) throws DeviceNotFound, DeviceAlreadyConnectedException, IOException
The method used when user wants to establish a connection between the current device and another connected device.
Parameters:
- index -> The position where the desired device is found in the list of last searched connected devices.
Throws:
- DeviceNotFound -> The device at the given index was not found.
- DeviceAlreadyConnectedException -> A connection between the devices already exists.
- IOException