diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-15 18:47:27 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-15 18:47:27 +0100 |
commit | 6f58c3a3ce15289e559360330896cfb0cc22ae4d (patch) | |
tree | eb227626101389495b8a7351da69c73290641505 /same/old/SameServiceImpl.java | |
parent | 043dc32807afc0e82b3b89e99bc4eea254fa9062 (diff) |
Move old SameService files out of the way.
Diffstat (limited to 'same/old/SameServiceImpl.java')
-rw-r--r-- | same/old/SameServiceImpl.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/same/old/SameServiceImpl.java b/same/old/SameServiceImpl.java new file mode 100644 index 0000000..27579b5 --- /dev/null +++ b/same/old/SameServiceImpl.java @@ -0,0 +1,60 @@ +package com.orbekk.same; + +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SameServiceImpl implements SameService { + private Logger logger = LoggerFactory.getLogger(getClass()); + private SameState sameState; + + public SameServiceImpl(SameState sameState) { + this.sameState = sameState; + } + + @Override + public void notifyNetwork(String networkName) { + logger.info("Notification from network " + networkName); + } + + @Override + public void participateNetwork(String networkName, String clientId, + String url) { + if (!networkName.equals(sameState.getNetworkName())) { + logger.warn("Client tried to join {}, but network name is {}.", + networkName, sameState.getNetworkName()); + return; + } + if (clientId.equals("") || url.equals("")) { + logger.warn("Missing client info: ClientId({}), URL({}).", + clientId, url); + return; + } + sameState.addParticipant(clientId, url); + } + + @Override + public void notifyParticipation(String networkName, String masterId) { + logger.info("Joining network {}. Master is {}", networkName, masterId); + // int i = 1; + // for (Map.Entry<String, String> e : participants.entrySet()) { + // String clientId = e.getKey(); + // String url = e.getValue(); + // logger.info(" {} participant {}: {}, {}", + // new Object[]{networkName, i, clientId, url}); + // i++; + // } + sameState.joinNetwork(networkName, masterId); + } + + @Override + public void setParticipants(Map<String, String> participants) { + sameState.setParticipants(participants); + } + + @Override + public void setState(String newState) { + sameState.setState(newState); + } +} |