IBM Worklight - 连接/重新连接:WL.Client.connect与connectOnStartup对比WL.Client.invokeProcedure [英] IBM Worklight - Connecting/Re-Connecting: WL.Client.connect vs. connectOnStartup vs. WL.Client.invokeProcedure

查看:257
本文介绍了IBM Worklight - 连接/重新连接:WL.Client.connect与connectOnStartup对比WL.Client.invokeProcedure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中,我们试图确定连接到服务器的最佳流程是什么 - 特别是在处理离线/在线场景等时。

In our project we are trying to figure our what the best process to connect to the server will be - especially when taking care of offline/online scenarios etc.

现在,对我们来说,似乎连接到WL服务器的所有三个选项都是相似的。无论我们使用什么选项,我们都可以完美地调用我们的适配器程序,并且我们会收到在控制台中设置的通知消息。
我们不确定直接更新 - 这还不能正常工作。

Right now, for us, it seems that all three options to connect to the WL server are similar. Whatever option we use, we can call our Adapter Procedures perfectly and we receive Notification Messages that are set in the console. We are not sure about Direct Update - this is not working properly yet.

这三种连接WL服务器的方式是否有任何重大差异,或基本上是在所有三种情况下执行的连接程序相同?

Are there any important differences between these three ways of connecting to the WL server, or is basically the same connection procedure being executed in all three cases?

连接之前WL.Client.init()怎么样?我们可以再次调用它(除了在我们使用WL.Client.connect手动连接之前我们的代码中的标准窗口加载EventListener)或者是init()应该只调用一次?

How about WL.Client.init() before connecting - could we call that again (in addition to the standard window load EventListener) in our code before we connect using a WL.Client.connect manually - or is init() supposed to be called only once?

绑定到这也是离线和重新连接。
据我在教程中读到,WL Client框架正在管理连接状态。这是否意味着当WL客户端通过这三种方式中的任何一种连接到服务器并且丢失了它的WLAN / 3G / 4G连接(或者由于互联网连接阻止程序而无法访问WL服务器)时它会自动重新连接(当再次提供与WL服务器的连接时,会定期尝试重新连接直到成功吗?

Tied to that is also offline and re-connecting. As far as I have read in the tutorials, the WL Client framework is managing the connection state. Does that mean that when the WL client is connected to the server through any of these three ways and loses it's WLAN/3G/4G connection (or it's access to the WL server due to internet connection blocker or so) it re-connects automatically (regularly tries to re-connect until successful) when a connection to the WL server is available again?

编辑

我在考虑提供更多低级别信息的事件或线程(不是WORKLIGHT_IS_CONNECTED) - 基本上是当设备丢失/获得WIFI / 3G / 4G连接和/或互联网连接时会触发的事件。或者是否只有使用WL.Device.getNetworkInfo()的轮询?

I was thinking about Events or Threads that provide more low-level information (not WORKLIGHT_IS_CONNECTED) - basically events that would be triggered when the device loses/gets WIFI/3G/4G connection and/or internet connection. Or is there only polling using WL.Device.getNetworkInfo() available?

使用Cordova事件如何:

Would the use of Cordova Event like:

document.addEventListener("offline", yourCallbackFunction, false);

提供接近的功能?

推荐答案

虽然这三种方式确实有一些相似之处,但它们之间的差异非常重要。

Though those three ways do have some similarities the differences between them are very important.

WL.Client.init()初始化客户端WL框架。

WL.Client.init() initializes client side WL framework.

WL.Client.connect()触发对WL服务器的连接请求。

WL.Client.connect() triggers connection request to WL server.

initOptions.connectOnStartup 定义在此期间是否会自动调用 WL.Client.connect() WL.Client.init()。

initOptions.connectOnStartup defines whether WL.Client.connect() will be invoked automatically during WL.Client.init().

一般情况下 - 即使你打电话给 WL.Client.invokeProcedure(),大多数功能(例如适配器,远程禁用)都会起作用。 code>而不调用 WL.Client.connect()。但有几件事情无法发挥作用:

In general - most of the functionality (e.g. adapters, remote disable) will function even if you call WL.Client.invokeProcedure() without calling WL.Client.connect(). But there are several things that will not function:


  1. 如果不调用,您将无法充分利用推送通知WL.Client.connect()

  2. WL.Client.connect()期间触发直接更新

  3. WL.Client.connect()将从服务器获取安全相关信息,例如领域的名称,无论用户是否在这些领域中进行了身份验证等。因此所有API如 WL.Client.getUserInfo .isAuthenticated() .getUserName()等不起作用。

  1. You will not be able to fully utilize push notifications without calling WL.Client.connect()
  2. Direct update is triggered during WL.Client.connect()
  3. WL.Client.connect() will get security related info from server, e.g. names of realms, whether user authenticated in those realms etc. Therefore all APIs like WL.Client.getUserInfo, .isAuthenticated(), .getUserName() etc will not function.

它是强烈建议您使用 WL.Client.connect()(或 initOptions.connectOnStartup = true )开始会话。

It is strongly recommended to start your session with WL.Client.connect() (or initOptions.connectOnStartup=true).

这篇关于IBM Worklight - 连接/重新连接:WL.Client.connect与connectOnStartup对比WL.Client.invokeProcedure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆