Ignore:
Timestamp:
11/28/19 14:40:48 (5 years ago)
Author:
bart
Message:

Release 1.1.0

Location:
profileconnection/src/main/java/geniusweb/profileconnection
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • profileconnection/src/main/java/geniusweb/profileconnection/FileProfileConnector.java

    r2 r9  
    1010
    1111import geniusweb.profile.Profile;
     12import tudelft.utilities.listener.DefaultListenable;
    1213
    1314/**
    1415 * ProfileInterface based on a plain filesystem UTF8 file.
    1516 */
    16 public class FileProfileConnector implements ProfileInterface {
     17public class FileProfileConnector extends DefaultListenable<Profile>
     18                implements ProfileInterface {
    1719        private final static ObjectMapper jackson = new ObjectMapper();
    1820        private final Profile profile;
     
    2527        public FileProfileConnector(String filename) throws IOException {
    2628                Path path = new File(filename).toPath();
    27                 String serialized = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
     29                String serialized = new String(Files.readAllBytes(path),
     30                                StandardCharsets.UTF_8);
    2831                profile = jackson.readValue(serialized, Profile.class);
    2932        }
  • profileconnection/src/main/java/geniusweb/profileconnection/ProfileInterface.java

    r1 r9  
    22
    33import geniusweb.profile.Profile;
     4import tudelft.utilities.listener.Listenable;
    45
    56/**
    67 * A container holding a modifyable profile. This interface allows testing.
    78 */
    8 public interface ProfileInterface {
     9public interface ProfileInterface extends Listenable<Profile> {
    910
    1011        /**
  • profileconnection/src/main/java/geniusweb/profileconnection/WebsocketProfileConnector.java

    r1 r9  
    1515
    1616import geniusweb.profile.Profile;
     17import tudelft.utilities.listener.DefaultListenable;
    1718import tudelft.utilities.logging.Reporter;
    1819
     
    2122 */
    2223@ClientEndpoint
    23 public class WebsocketProfileConnector implements ProfileInterface {
     24public class WebsocketProfileConnector extends DefaultListenable<Profile>
     25                implements ProfileInterface {
    2426        private final static ObjectMapper jackson = new ObjectMapper();
    2527        private static final int TIMEOUT_MS = 2000;
     
    5658                // this will be called every time the profile changes.
    5759                logger.log(Level.FINE, "Received profile: " + message);
    58                 this.profile = jackson.readValue(message, Profile.class);
     60                profile = jackson.readValue(message, Profile.class);
     61                notifyListeners(profile);
    5962        }
    6063
Note: See TracChangeset for help on using the changeset viewer.