Access Server from Client

We successfully started our server, and the next step is to access it from a client!

And this is very simple: just create an object of our Interface using LPFCP Java library and use it as it was regular (local) object of the Interface:

fun main() {
    // Creating a calculator object from Calculator interface with LPFCP
    val calculator: Calculator = LPFCP.getProcessor<Calculator>(
        "http://localhost:8080/lpfcp" // If the calculator server is hosted on the same machine
    )

    // Call Calculator functions as the calculator was just a regular implementation
    println(calculator.add(1, 2))       // -> 3
    println(calculator.subtract(5, 3))  // -> 2
}

Congratulations 🎉! You just did your first LPFCP function call!

Last updated