GW Java API

下载依赖文件

cutos-gw-app-lib-3.0.0.jar

引入依赖库
import com.sts.cutos.gw.app.AppService;
import com.sts.cutos.gw.app.IPC;
初始化建立IPC连接
IPC gwIPC = new IPC(gwUrl, userId, password);
appService = new AppService(gwIPC);
gwIPC.connect(callback);
  • callback: 回调函数。需要成功连接IPC后执行注册app,因此在回调函数中注册app。
举例
IPC gwIPC = new IPC(gwUrl, userId, password);
appService = new AppService(gwIPC);
gwIPC.connect((status, message) -> {
  logger.info("on ready {} {}", status, message);
  if (!"success".equals(status)) {
    return;
  }
  appService.registerAppAdmin();
});
  • 返回结果示例:
on ready success Initialization succeeded.

appService.registerAppAdmin

注册应用服务
  appService.registerAppAdmin(appAdminName, appAdminHome, callback);
  • appAdminName: app名称,例如"体检一体机应用服务";
  • appAdminHome: app运行地址,例如自身启动,端口为5000"http://localhost:5000/index.html";
  • callback: 回调函数。包含两个参数topic以及payload;
举例
  appService.registerAppAdmin(appAdminName, appAdminHome, (topic, payload) -> {
    logger.info("register ack {}", payload);
    JSONObject jsonObject = JSON.parseObject(payload);
    String result = jsonObject.getJSONObject("response").getString("result");
  });
  • 返回结果示例:
register ack {"response":{"result":"success"}}

appService.validateAppAdminSession

验证CUTOS官网session
 appService.validateAppAdminSession(appId, session)
  • appId: 接入CUTOS官网返回的appId;
  • session: 接入CUTOS官网返回的session;

results matching ""

    No results matching ""