From 9ef330b2917410409830df47b8caa35301a2eefe Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 18 Jul 2007 22:46:49 +0000 Subject: [PATCH] Added applyToNodes(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4778 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/peer/server/PeerManager.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/java/com/threerings/presents/peer/server/PeerManager.java b/src/java/com/threerings/presents/peer/server/PeerManager.java index 92aa8bb35..beb31daa3 100644 --- a/src/java/com/threerings/presents/peer/server/PeerManager.java +++ b/src/java/com/threerings/presents/peer/server/PeerManager.java @@ -103,6 +103,12 @@ public class PeerManager public T lookup (NodeObject nodeobj); } + /** Used by {@link #applyToNodes}. */ + public static interface Operation + { + public void apply (NodeObject nodeobj); + } + /** * Creates a peer manager which will create a {@link NodeRepository} which will be used to * publish our existence and discover the other nodes. @@ -258,6 +264,21 @@ public class PeerManager return value; } + /** + * Applies the supplied operation to all {@link NodeObject}s. The operation should not modify + * the objects unless you really know what you're doing. more likely it will summarize + * information contained therein. + */ + public void applyToNodes (Operation op) + { + op.apply(_nodeobj); + for (PeerNode peer : _peers.values()) { + if (peer.nodeobj != null) { + op.apply(peer.nodeobj); + } + } + } + /** * Returns true if the supplied peer credentials match our shared secret. */