Last active
December 11, 2015 02:38
-
-
Save patelm5/4531571 to your computer and use it in GitHub Desktop.
Simple Broadcast Service for Atmosphere.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class BroadcastService { | |
private final static Logger logger = Logger.getLogger(BroadcastService.class.getName()); | |
private Map<String, Broadcaster> broadcastTokens = new ConcurrentHashMap<String, Broadcaster>(); | |
public void broadcast(String message) { | |
for (Broadcaster token : broadcastTokens.values()) { | |
token.broadcast(message); | |
logger.info("Broadcasting message:"+message); | |
} | |
} | |
public void addBroadcastToken(String channel, Broadcaster token) { | |
broadcastTokens.put(channel, token); | |
} | |
public void destroyBroadcastToken(String channel) { | |
Broadcaster token = broadcastTokens.get(channel); | |
if (token != null) { | |
token.destroy(); | |
broadcastTokens.remove(channel); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment