瀏覽代碼

Fixed a comment to be more accurate with respect
to handler method argument types.
Fixed a small bug in how auto-detect worked. It
was too greedy in looking for two-argument methods
and would somehow allow methods that took a first
argument that was not a connection type.

Paul Speed 10 年之前
父節點
當前提交
8b34e4890a
共有 1 個文件被更改,包括 11 次插入10 次删除
  1. 11 10
      jme3-networking/src/main/java/com/jme3/network/util/AbstractMessageDelegator.java

+ 11 - 10
jme3-networking/src/main/java/com/jme3/network/util/AbstractMessageDelegator.java

@@ -91,9 +91,8 @@ public abstract class AbstractMessageDelegator<S extends MessageConnection>
      *  Returns true if the specified method is valid for the specified
      *  message type.  This is used internally during automapping to
      *  provide implementation specific filting of methods.
-     *  This implementation checks for methods that take either no
-     *  arguments, the connection and message type arguments (in that order), 
-     *  or just the message type or connection argument.
+     *  This implementation checks for methods that take either the connection and message 
+     *  type arguments (in that order) or just the message type.
      */
     protected boolean isValidMethod( Method m, Class messageType ) {
  
@@ -106,13 +105,15 @@ public abstract class AbstractMessageDelegator<S extends MessageConnection>
         if( parms.length != 2 && parms.length != 1 ) {
             log.finest("Parameter count is not 1 or 2");
             return false;
-        }            
-        int connectionIndex = parms.length > 1 ? 0 : -1;
-        int messageIndex = parms.length > 1 ? 1 : 0;
-
-        if( connectionIndex > 0 && !MessageConnection.class.isAssignableFrom(parms[connectionIndex]) ) {
-            log.finest("First paramter is not a MessageConnection or subclass.");
-            return false;
+        }                   
+        int messageIndex = 0;
+        if( parms.length > 1 ) {
+            if( MessageConnection.class.isAssignableFrom(parms[0]) ) {
+                messageIndex++;
+            } else {
+                log.finest("First paramter is not a MessageConnection or subclass.");
+                return false;
+            }
         }
  
         if( messageType == null && !Message.class.isAssignableFrom(parms[messageIndex]) ) {