Search code examples
iosibm-mobilefirst

Check Worklight Client connection state


I'm working on a native iOS app that is using IBM Worklight server adapters, in my code every time I want to invoke a procedure I'm calling the WLClient().wlConnectWithDelegate(self) and then calling the adapter, is there a way that would let me check the connection status of the client before I invoke the adapter procedure?


Solution

  • There is no such API provided by the Worklight framework.

    The idea behind the connect API is to establish a session between the client and server, negating the possibility for example of race condition (such as two adapter requests to the server, each getting its own session, potentially causing trouble), in addition to delivering data on headers that is no available in an adapter request compared to connect request.

    I think that instead of making a connect request before invocation you can do it in an early stage in the app's lifecycle, as well as whenever the app returns to the foreground, to ensure that a session was established. This, coupled together wit an appropriate session timeout set in worklight.properties on the server-side.

    More here: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/hello-world/connecting-to-the-mobilefirst-server/