diff options
| author | Nils Schwabe | 2014-07-10 16:08:36 +0200 |
|---|---|---|
| committer | Nils Schwabe | 2014-07-10 16:08:36 +0200 |
| commit | c89abbfa830876b7298eb96896a642bc74589651 (patch) | |
| tree | ee3b0707be612d9147d23632713c61c52c6d27be /src/main/java/org/openslx/imagemaster/serverconnection/DownloadingClient.java | |
| parent | Remove unintentionally added f3 docs (diff) | |
| download | masterserver-c89abbfa830876b7298eb96896a642bc74589651.tar.gz masterserver-c89abbfa830876b7298eb96896a642bc74589651.tar.xz masterserver-c89abbfa830876b7298eb96896a642bc74589651.zip | |
Add some better thread synchonization
Restructure some classes
Fix small connection issues
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/serverconnection/DownloadingClient.java')
| -rw-r--r-- | src/main/java/org/openslx/imagemaster/serverconnection/DownloadingClient.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/DownloadingClient.java b/src/main/java/org/openslx/imagemaster/serverconnection/DownloadingClient.java new file mode 100644 index 0000000..0acfa42 --- /dev/null +++ b/src/main/java/org/openslx/imagemaster/serverconnection/DownloadingClient.java @@ -0,0 +1,75 @@ +package org.openslx.imagemaster.serverconnection; + +import java.util.HashMap; +import java.util.List; + +/** + * Helper class for the ImageProcessor to know some things about the downloading client + * + */ +public class DownloadingClient +{ + + public final HashMap<String, ImageInfos> downloadingImages = new HashMap<>(); + + DownloadingClient() + { + } + + public void addDownload( String uuid, List<Integer> list, String token ) + { + downloadingImages.put( uuid, new ImageInfos( uuid, list, token ) ); + } + + public void removeDownload( String uuid ) + { + downloadingImages.remove( uuid ); + } + + public boolean isDownloading( String uuid ) + { + return downloadingImages.containsKey( uuid ); + } + + public boolean hasDownloads() + { + return (downloadingImages.size() > 0); + } + + public List<Integer> getLastRequestedBlocks( String uuid ) + { + if ( !downloadingImages.containsKey( uuid ) ) + return null; + return downloadingImages.get( uuid ).lastRequestedBlocks; + } + + public void requestBlocks( String uuid, List<Integer> list ) + { + if ( !downloadingImages.containsKey( uuid ) ) + return; + downloadingImages.get( uuid ).lastRequestedBlocks = list; + } + + public String getToken( String uuid ) + { + if ( !downloadingImages.containsKey( uuid ) ) + return null; + return downloadingImages.get( uuid ).token; + } + + class ImageInfos + { + + public final String uuid; + public final String token; + private List<Integer> lastRequestedBlocks; + + ImageInfos(String uuid, List<Integer> list, String token) + { + this.uuid = uuid; + this.lastRequestedBlocks = list; + this.token = token; + } + } + +} |
