diff options
author | Danny van Heumen <danny@dannyvanheumen.nl> | 2015-02-11 00:08:11 +0100 |
---|---|---|
committer | Danny van Heumen <danny@dannyvanheumen.nl> | 2015-03-13 19:35:54 +0100 |
commit | a9f396f3274e72a8f0801425bb57425e560e9fa6 (patch) | |
tree | 98efd2f7a1a76a3b1c5bba254062db4437672220 /src | |
parent | f9be5938d1e815a69e50fda1b6b544008e29a922 (diff) | |
download | jitsi-a9f396f3274e72a8f0801425bb57425e560e9fa6.zip jitsi-a9f396f3274e72a8f0801425bb57425e560e9fa6.tar.gz jitsi-a9f396f3274e72a8f0801425bb57425e560e9fa6.tar.bz2 |
Use MONITOR maximum list size. Some clean-up.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/irc/MonitorPresenceWatcher.java | 27 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java | 12 |
2 files changed, 27 insertions, 12 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/MonitorPresenceWatcher.java b/src/net/java/sip/communicator/impl/protocol/irc/MonitorPresenceWatcher.java index 7001c61..37eb940 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/MonitorPresenceWatcher.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/MonitorPresenceWatcher.java @@ -58,7 +58,8 @@ class MonitorPresenceWatcher */ MonitorPresenceWatcher(final IRCApi irc, final IIRCState connectionState, final SortedSet<String> nickWatchList, - final OperationSetPersistentPresenceIrcImpl operationSet) + final OperationSetPersistentPresenceIrcImpl operationSet, + final int maxListSize) { if (irc == null) { @@ -77,9 +78,8 @@ class MonitorPresenceWatcher } this.nickWatchList = nickWatchList; this.irc.addListener(new MonitorReplyListener(operationSet)); - setUpMonitor(this.irc, this.nickWatchList); + setUpMonitor(this.irc, this.nickWatchList, maxListSize); // FIXME add basic poller watcher as a fallback method - // FIXME adhere to limits according to ISUPPORT MONITOR=# entry LOGGER.debug("MONITOR presence watcher initialized."); } @@ -90,13 +90,18 @@ class MonitorPresenceWatcher * still being initialized. */ private static void setUpMonitor(final IRCApi irc, - final SortedSet<String> nickWatchList) + final SortedSet<String> nickWatchList, final int maxListSize) { - final List<String> current; + List<String> current; synchronized (nickWatchList) { current = new LinkedList<String>(nickWatchList); } + if (current.size() > maxListSize) + { + // cut off list to maximum number of entries allowed by server + current = current.subList(0, maxListSize); + } final int maxLength = 510 - MONITOR_ADD_CMD_STATIC_OVERHEAD; final StringBuilder query = new StringBuilder(); for (String nick : current) @@ -158,7 +163,6 @@ class MonitorPresenceWatcher */ private static final int IRC_RPL_MONOFFLINE = 731; - // Unused constants. Listed for completeness. // /** // * Numeric message id for MONLIST entry. // */ @@ -170,6 +174,12 @@ class MonitorPresenceWatcher // private static final int IRC_RPL_ENDOFMONLIST = 733; /** + * Error message signaling full list. Nick list provided are all nicks + * that failed to be added to the monitor list. + */ + private static final int IRC_ERR_MONLISTFULL = 734; + + /** * Operation set persistent presence instance. */ private final OperationSetPersistentPresenceIrcImpl operationSet; @@ -228,6 +238,11 @@ class MonitorPresenceWatcher } monitoredNickList.addAll(acknowledged); break; + case IRC_ERR_MONLISTFULL: + LOGGER.debug("MONITOR list full. Nick was not added. " + + "Fall back Basic Poller will be used if it is enabled. (" + + msg.getText() + ")"); + break; } } diff --git a/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java b/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java index 7e1ca52..da30cd0 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/PresenceManager.java @@ -19,16 +19,16 @@ import com.ircclouds.irc.api.state.*; /** * Manager for presence status of IRC connection. * - * There is (somewhat primitive) support for online presence by periodically - * querying IRC server with ISON requests for each of the members in the contact - * list. + * There is support for online presence by polling (periodically querying IRC + * server with ISON requests) for each of the members in the contact list or, if + * supported by the IRC server, for the MONITOR command to subscribe to presence + * notifications for the specified nick. * * TODO Support for 'a' (Away) user mode. (Check this again, since I also see * 'a' used for other purposes. This may be one of those ambiguous letters that * every server interprets differently.) * - * TODO Improve presence watcher by using WATCH or MONITOR. (Monitor does not - * seem to support away status, though) + * TODO Additionally add support for pub/sub presence notifications using WATCH. * * @author Danny van Heumen */ @@ -161,7 +161,7 @@ public class PresenceManager { this.watcher = new MonitorPresenceWatcher(this.irc, this.connectionState, - nickWatchList, this.operationSet); + nickWatchList, this.operationSet, this.isupportMonitor); } } else |