Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public interface StateRelay
Known subtypesRestStateRelay
Carries state between devices the platform will not carry it between – an iPhone and an Android tablet, two devices that are never in the same room, a phone and the web build.
Codename One ships no server for this. A relay is the application’s own endpoint, which is
also the only honest arrangement: the relay has to know which states belong to the same
person, and that is the app’s account system, not the framework’s. RestStateRelay covers
the common case over HTTPS; implement this interface directly for anything else.
Both methods are called from a background thread and may block. Neither is called on the event
dispatch thread, so ordinary blocking com.codename1.io code is correct here.
Methods
public abstract void publish(AppState state)
throws IOException | Sends a state. |
public abstract AppState fetch()
throws IOException | Asks for the newest state this user has on any device. |
Method details
publish
public abstract void publish(AppState state)
throws IOExceptionParameters
stateAppState- the state to send
Throws
java.io.IOException- when the send failed. The framework logs it and keeps the state, which the next checkpoint’s publisher sends – unless a newer state has superseded it by then, or the user signed out in between. It is not retried on a timer: one attempt per change beats spinning against an endpoint that is down.
fetch
public abstract AppState fetch()
throws IOExceptionReturns
Throws
java.io.IOException- when the fetch failed