public String processInput ( String input ) { JsonObject object ; try { object = gs . fromJson ( input , JsonObject . class ) ; } catch ( Throwable t ) { return "{ \"status\" : \"fail\", \"error\" : \"Failed to parse input\" }" ; } String command = object . get ( "command" ) . getAsString ( ) ; JsonObject payload ; if ( ! object . has ( "payload" ) ) { payload = new JsonObject ( ) ; } else { payload = object . get ( "payload" ) . getAsJsonObject ( ) ; } CommandStatus status ; try { status = dispatch ( command , payload ) ; } catch ( Throwable t ) { status = new CommandStatus ( ) ; status . fail ( t ) . setPayload ( payload ) ; } return status . toString ( ) ; }
Process the input sent from the client utilizing the mock server and return the response .