Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Resident App

Laura Partac edited this page Jun 9, 2022 · 9 revisions

Tree

Actions

DeleteDeal

PushDeal

TreeActionsEnum

TreeDeal

FileSystemTree

TreeDirectory

WildcardTreeDirectory

ConnectivityResident

The class responsible for the communication between two devices which is established by sending actions: fetch, sync and delete.

Class Header

Imports

import com.google.gson.Gson;
import connectivity.Peer;
import connectivity.connection.Connection;
import george.tree.FileSystemTree;
import george.tree.TreeDirectory;
import george.tree.actions.PushDeal;
import george.tree.actions.TreeActionsEnum;
import george.tree.actions.TreeDeal;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

Header

public class ConnectivityResident extends Thread

Class Summary

Attributes

Summary

private Peer peer;
private SynchronizedDirectory synchronizedDirectory;
private List<Connection> lastSearch = new ArrayList<>();

Details 1. peer

private Peer peer;

An attribute representing an instance of the object Peer which keeps track of all the connections made in the network, allowing devices to connect to each other.

2. synchronizedDirectory

private SynchronizedDirectory synchronizedDirectory;

The attribute representing the object related to the folder which is destined to store all the files that will be syncronized.

3. lastSearch

private List<Connection> lastSearch = new ArrayList<>();

A list of connected devices.

Constructors

A constructor with arguments:

public ConnectivityResident(Peer peer, SynchronizedDirectory synchronizedDirectory)

A constructor with no arguments:

public ConnectivityResident()

Methods

Summary

public Peer getPeer()
public void setSynchronizedDirectory(SynchronizedDirectory synchronizedDirectory)
public List<Connection> getConnectedDevices()
public List<Connection> getLastSearch()
public void setPeer(Peer peer)
private void sendFileSystemTree(Connection connection, FileSystemTree fileSystemTree) throws FileNotFoundException, IOException
private void sendAction(Connection connection, TreeActionsEnum action) throws IOException
public void fetchFiles(Connection connection) throws  IOException
public void syncFiles(Connection connection) throws IOException
private void sendModifiedFiles(Connection connection, FileSystemTree fileSystemTree) throws IOException
public void incomingAction(Connection connection, FileSystemTree fileSystemTree)
public void run()

SynchronizedDirectory

Testing

Clone this wiki locally