Create the Interface

Working with LPFCP Java library is very similar to working with common Kotin/Java things — you also create an Interface, then implement it in some Class, create an instance of that class and then having the Interface you can call methods of the Class object.

So let's start with creating the Interface. That Interface must be the same for both client and server side. For example, let's create a simple Interface for calculator app, which can add and substract integers:

interface Calculator {
    fun add(a: Int, b: Int): Int
    fun subtract(a: Int, b: Int): Int
}

You can either just duplicate this code in client and server sides or make this Interface shared across client and server sides using multi-module project structure with shared, client and server modules. For an example of such project with multi-module structure see https://github.com/likespro/lpfcp-java/tree/main/examples/calculator-kotlin

Last updated