From ac393d3084d59d686843f71a1685a4391cbb610b Mon Sep 17 00:00:00 2001 From: tduva Date: Sun, 18 Sep 2016 15:38:25 +0200 Subject: [PATCH] Update comments, help, typo --- .../gui/components/help/help-releases.html | 3 ++ src/chatty/util/api/pubsub/Client.java | 12 ++++-- src/chatty/util/api/pubsub/Manager.java | 38 +++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/chatty/gui/components/help/help-releases.html b/src/chatty/gui/components/help/help-releases.html index 95aab3866..c5eb446dd 100644 --- a/src/chatty/gui/components/help/help-releases.html +++ b/src/chatty/gui/components/help/help-releases.html @@ -45,6 +45,9 @@

Version 0.8.4 (This one!) (2016-??-??) [back to top]

+

As broadcaster or mod you can now view the actions of other mods in a + separate window via Extra - Moderation Log or enable mod + actions to appear as extra messages directly in chat (Main - Settings - Messages).

 - Added Emoji support
 - Added displaying of received Cheers/Bits (Cheer Badges/sending Cheers not yet)        
diff --git a/src/chatty/util/api/pubsub/Client.java b/src/chatty/util/api/pubsub/Client.java
index 4c82c54d6..dab1bb8b0 100644
--- a/src/chatty/util/api/pubsub/Client.java
+++ b/src/chatty/util/api/pubsub/Client.java
@@ -122,6 +122,11 @@ public long getDelay() {
     }
     
     public synchronized void connect(String server) {
+        /**
+         * Only connect once, which is intended to stay connected forever. If
+         * manually disconnecting/connecting again should be a thing, some stuff
+         * may have to be changed.
+         */
         if (connecting) {
             return;
         }
@@ -159,11 +164,10 @@ private synchronized void close() {
         }
     }
     
-    public synchronized void send(String mesage) {
+    public synchronized void send(String message) {
         if (s != null && s.isOpen()) {
-            s.getAsyncRemote().sendText(mesage);
-            handler.handleSent(mesage);
-            System.out.println("SENT:"+mesage);
+            s.getAsyncRemote().sendText(message);
+            handler.handleSent(message);
         }
     }
     
diff --git a/src/chatty/util/api/pubsub/Manager.java b/src/chatty/util/api/pubsub/Manager.java
index 30793aac6..f998f08ec 100644
--- a/src/chatty/util/api/pubsub/Manager.java
+++ b/src/chatty/util/api/pubsub/Manager.java
@@ -29,7 +29,16 @@ public class Manager {
     private final Client c;
     private final String server;
 
+    /**
+     * Storage of user ids for easier lookup to turn an id into a channel name.
+     */
     private final Map userIds = Collections.synchronizedMap(new HashMap());
+    
+    /**
+     * Channels to listen on for the modlog, storing the id of the channel as
+     * well. If the id is -1, still waiting for the user id and not listening
+     * yet.
+     */
     private final Map modLogListen = Collections.synchronizedMap(new  HashMap());
     
     private volatile Timer pingTimer;
@@ -96,6 +105,12 @@ public String getStatus() {
         return c.getStatus();
     }
     
+    /**
+     * Set the username of this Chatty user, which is used for listening to the
+     * correct mod log topic (which requires the mod user id).
+     * 
+     * @param username 
+     */
     public void setLocalUsername(String username) {
         if (localUsername == null || !localUsername.equals(username)) {
             this.localUsername = username;
@@ -103,6 +118,13 @@ public void setLocalUsername(String username) {
         }
     }
     
+    /**
+     * Start receiving the modlog for the given channel (username). The token is
+     * requires to authenticate.
+     * 
+     * @param username
+     * @param token 
+     */
     public void listenModLog(String username, String token) {
         if (!hasServer()) {
             return;
@@ -120,6 +142,11 @@ public void listenModLog(String username, String token) {
         }
     }
     
+    /**
+     * Stop reciving the modlog for the given channel (username).
+     * 
+     * @param username 
+     */
     public void unlistenModLog(String username) {
         synchronized(modLogListen) {
             if (modLogListen.containsKey(username)) {
@@ -131,11 +158,22 @@ public void unlistenModLog(String username) {
         }
     }
     
+    /**
+     * Get the user id for the given username, or wait until it has been
+     * requested and act on it then.
+     * 
+     * @param username A valid Twitch username
+     * @return The user id, or -1 if user id still has to be requested
+     */
     private long getUserId(String username) {
         long userId = api.getUserId(username, new UserIDs.UserIDListener() {
 
             @Override
             public void setUserId(String username, long userId) {
+                /**
+                 * When the user id has been requested. If the user id is
+                 * already cached, this listener won't be stored.
+                 */
                 Manager.this.setUserId(username, userId);
             }
         });