java/protoCtrl/src/main/java/com/pravala/protocol/ctrl/ProtocolMessageHandler.java
public void handleMessage ( Message baseMessage ) throws CodecException
    {
        if ( baseMessage == null )
        {
            Log.e ( TAG, "handleMessage called with null baseMessage" );
            return;
        }

        if ( !baseMessage.hasType() )
        {
            Log.e ( TAG, "Failed to decode message: message has no type" );
            return;
        }

        if ( !baseMessage.getType().equals ( messageType ) )
        {
            Log.w ( TAG, "Failed to decode message: message type [" + baseMessage.getType()
                       + "] does not match this handler's type " + messageName + " [" + messageType + "]" );
            return;
        }

        // Message.generate() throws an exception on failure. It never returns null.
        @SuppressWarnings ( "unchecked" )
        final MessageType decodedMessage = ( MessageType ) messageObject.generate ( baseMessage );

        if ( decodedMessage == null )
        {
            Log.e ( TAG, "Failed to generate a message; generate() returned null; Message type: "
                       + messageType + "; Message name: " + messageName );
            return;
        }

        Log.v ( TAG, "Decoded message of type " + decodedMessage.getClass().getName()
                   + " [" + messageType + "];" );

        receivedMessage ( decodedMessage );
    }
/**
     * Called when a base message that looks like the message type this handler supports is received.
     * It will try to deserialize it, and call the 'receivedMessage' callback
     * @param baseMessage The base message to deserialize
     * @throws CodecException
     */
Called when a base message that looks like the message type this handler supports is received.
It will try to deserialize it, and call the 'receivedMessage' callback
@param baseMessage The base message to deserialize
@throws CodecException
Called when a base message that looks like the message type this handler supports is received . It will try to deserialize it and call the ' receivedMessage ' callback @param baseMessage The base message to deserialize @throws CodecException
public void handleMessage ( Message baseMessage ) throws CodecException
    {
        if ( baseMessage == null )
        {
            Log.e ( TAG, "handleMessage called with null baseMessage" );
            return;
        }
        if ( !baseMessage.hasType() )
        {
            Log.e ( TAG, "Failed to decode message: message has no type" );
            return;
        }
        if ( !baseMessage.getType().equals ( messageType ) )
        {
            Log.w ( TAG, "Failed to decode message: message type [" + baseMessage.getType()
                       + "] does not match this handler's type " + messageName + " [" + messageType + "]" );
            return;
        }
        @SuppressWarnings ( "unchecked" )
        final MessageType decodedMessage = ( MessageType ) messageObject.generate ( baseMessage );
        if ( decodedMessage == null )
        {
            Log.e ( TAG, "Failed to generate a message; generate() returned null; Message type: "
                       + messageType + "; Message name: " + messageName );
            return;
        }
        Log.v ( TAG, "Decoded message of type " + decodedMessage.getClass().getName()
                   + " [" + messageType + "];" );
        receivedMessage ( decodedMessage );
    }
public void handleMessage ( Message baseMessage ) throws CodecException { if ( baseMessage == null ) { Log . e ( TAG , "handleMessage called with null baseMessage" ) ; return ; } if ( ! baseMessage . hasType ( ) ) { Log . e ( TAG , "Failed to decode message: message has no type" ) ; return ; } if ( ! baseMessage . getType ( ) . equals ( messageType ) ) { Log . w ( TAG , "Failed to decode message: message type [" + baseMessage . getType ( ) + "] does not match this handler's type " + messageName + " [" + messageType + "]" ) ; return ; } @ SuppressWarnings ( "unchecked" ) final MessageType decodedMessage = ( MessageType ) messageObject . generate ( baseMessage ) ; if ( decodedMessage == null ) { Log . e ( TAG , "Failed to generate a message; generate() returned null; Message type: " + messageType + "; Message name: " + messageName ) ; return ; } Log . v ( TAG , "Decoded message of type " + decodedMessage . getClass ( ) . getName ( ) + " [" + messageType + "];" ) ; receivedMessage ( decodedMessage ) ; }
Called when a base message that looks like the message type this handler supports is received.
Called when a base message that looks like the message type this handler supports is received .
// Message.generate() throws an exception on failure. It never returns null.