]> jfr.im git - irc/rizon/acid.git/commitdiff
factor out a common TS check into Message
authorchristinaa <redacted>
Tue, 29 Aug 2017 18:11:00 +0000 (12:11 -0600)
committerchristinaa <redacted>
Tue, 29 Aug 2017 18:11:00 +0000 (12:11 -0600)
acid/src/main/java/net/rizon/acid/core/Message.java

index f6fb4da5cb9c49a4ac42beb61ba65a0f739bb835..8e66aed29efe06d229f1e650a2fc1da73b8ea6a9 100644 (file)
@@ -29,6 +29,24 @@ public abstract class Message
                messages.put(name.toUpperCase(), this);
        }
 
+       /*
+        * TS6 spec says that if the TS in the message is greater, the 
+        * message should be dropped. do that check here. this is here
+        * to mostly support TS checks in TMODE and BMASK without
+        * copy-pasting shit.
+        */
+       protected boolean shouldDropTsMessage(Integer oldTS, String newTS) {
+               try
+               {
+                       return (Integer.parseInt(newTS) > oldTS);
+               }
+               catch (NumberFormatException ex)
+               {
+                       ex.printStackTrace();
+                       return true;
+               }
+       }
+
        public void onUser(User source, String[] params) { }
        public void onServer(Server source, String[] params) { }
        public void on(String source, String[] params) { }