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);
举例
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;