GW Java API
Download dependencies
cutos-gw-app-lib-3.0.0.jar
Introduce dependent libraries
import com.sts.cutos.gw.app.AppService;
import com.sts.cutos.gw.app.IPC;
Initialize IPC connection
IPC gwIPC = new IPC(gwUrl, userId, password);
appService = new AppService(gwIPC);
gwIPC.connect(callback);
- callback: callback function. The registration app needs to be executed after successfully connecting to IPC, so the app is registered in the callback function.
Example
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
Register application service
appService.registerAppAdmin(appAdminName, appAdminHome, callback);
- appAdminName: app name, such as "All-in-one physical examination machine application service";
- appAdminHome: app running address, for example, when it starts itself, the port is 5000 "http://localhost:5000/index.html";
- callback: callback function. Contains two parameters topic and payload;
Example
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
Verify CUTOS official website session
appService.validateAppAdminSession(appId, session)
- appId: the appId returned by accessing the CUTOS official website;
- session: the session returned by accessing the CUTOS official website;