@ Override public void handleMessage ( Object objectToProcess ) { //There is an error... if ( objectToProcess instanceof Error ) { Error fluidError = ( ( Error ) objectToProcess ) ; this . errors . add ( fluidError ) ; //Do a message callback... if ( this . messageReceivedCallback != null ) { this . messageReceivedCallback . errorMessageReceived ( fluidError ) ; } //If complete future is provided... if ( this . completableFuture != null ) { this . completableFuture . completeExceptionally ( new FluidClientException ( fluidError . getErrorMessage ( ) , fluidError . getErrorCode ( ) ) ) ; } } //No Error... else { JSONObject jsonObject = ( JSONObject ) objectToProcess ; //Uncompress the compressed response... if ( this . compressedResponse ) { CompressedResponse compressedResponse = new CompressedResponse ( jsonObject ) ; byte [ ] compressedJsonList = UtilGlobal . decodeBase64 ( compressedResponse . getDataBase64 ( ) ) ; byte [ ] uncompressedJson = null ; try { uncompressedJson = this . uncompress ( compressedJsonList ) ; } catch ( IOException eParam ) { throw new FluidClientException ( "I/O issue with uncompress. " + eParam . getMessage ( ) , eParam , FluidClientException . ErrorCode . IO_ERROR ) ; } jsonObject = new JSONObject ( new String ( uncompressedJson ) ) ; } T messageForm = this . getNewInstanceBy ( jsonObject ) ; //Add to the list of return values... this . returnValue . add ( messageForm ) ; //Completable future is set, and all response messages received... if ( this . completableFuture != null ) { String echo = messageForm . getEcho ( ) ; if ( echo != null && ! echo . trim ( ) . isEmpty ( ) ) { this . expectedEchoMessagesBeforeComplete . remove ( echo ) ; } //All expected messages received... if ( this . expectedEchoMessagesBeforeComplete . isEmpty ( ) ) { this . completableFuture . complete ( this . returnValue ) ; } } //Do a message callback... if ( this . messageReceivedCallback != null ) { this . messageReceivedCallback . messageReceived ( messageForm ) ; } } }
Handles the message . If there was an error the object will be Error If there was no error the object will be JSONObject